Tic tac, tic tac........ but less two tic? (='.'=)

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Tic tac, tic tac........ but less two tic? (='.'=)

Post by Mariasole » Wed Jun 28, 2017 3:55 pm

Hello everyone!

I have a stupid question :oops: , but it's days I try and I can not find a solution :shock: .
In the end I decided to ask for help from experts! Gentlemen, of course! :D

I'm trying to do simple timetable operations, not dependent on fully dates. Only timetables. Simple stuff (in natural language!).

Example:
What time is the 6:30 less than a minute? -----> 6:29
And the 23 and 58 less a minute? -------> 23:57
And the 23 and 59 plus two minutes? ------> 00:01
And the 18:35 plus 37 minutes? --------> ??? I need LC function!!! :wink:

I tried to use DateFormat function, but I do not understand the method without using a specific day.
I know someone is now laughing !!!! Let me also laugh at me! :lol: :lol: :lol:

:shock:

Thanks to all those who want to give me a hand!

Mariasole
(='.'=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Klaus » Wed Jun 28, 2017 4:04 pm

Hola Maria,

OK, here is mine :D
hand.jpg
hand.jpg (30.81 KiB) Viewed 7063 times
Try this:

Code: Select all

on mouseUp
   ## I'm german so to avoid english time with AM/PM I do:
   set the usesystemdate to TRUE
   put "18:35" into tTime
   convert tTime to seconds
   add 37*60 to tTime
   convert tTime to short time
   put tTime ## -> 19:12
end mouseUp
Best

Klaus

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by MaxV » Fri Jun 30, 2017 12:44 pm

This is the function you need:

########CODE to copy and paste#######
on mouseUp
put libdate_addminutes("18:35",37)
end mouseUp

function libdate_addminutes pTime, pMinutes
#pTime format = "13:15" or 13:15:59"
#pminutes is a integer positive or negative
set itemdel to ":"
put item 1 of ptime into tOre
put item 2 of ptime into tMinuti
put item 3 of ptime into tSecondi
put tMinuti + pMinutes into tMinuti
if pMinutes > 0 then
put tOre + floor(tMinuti / 60) into tOre
else
put tOre - floor(tMinuti / 60) into tOre
end if
puttMinuti mod 60 into tMinuti
put tOre mod 24 into tOre
if the number of chars of tMinuti is 1 then put 0 before tMinuti
if the number of chars of tOre is 1 then put 0 before tOre
if tSecondi is empty then
return (tOre & ":" & tMinuti )
else
return (tOre & ":" & tMinuti & ":" & tSecondi )
end if
end libdate_addminutes
#####END OF CODE generated by http://tinyurl.com/j8xf3xq with livecode 9.0.0-dp-6#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Mariasole » Fri Jun 30, 2017 2:03 pm

Hey Klaus!
Then you are a friend of my uncle! :wink:

Image

Thanks for your help! Now I'll start experimenting! :D

Thanks also to you Max! :D I'll also try your "expanded" solution!

Thanks again to everyone!

Mariasole
(='.'=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Klaus » Fri Jun 30, 2017 2:09 pm

Tony is your uncle? Wayyyy cool! :D

Mariasole
Posts: 235
Joined: Tue May 07, 2013 9:38 pm

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Mariasole » Tue Jul 04, 2017 2:00 pm

In a world where we are all sisters and brothers, he is a third degree uncle :wink:

(='.'=)
"I'm back" - The Cyberdyne Systems Model 101 Series 800 Terminator

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Klaus » Tue Jul 04, 2017 3:40 pm

Mariasole wrote:In a world where we are all sisters and brothers, he is a third degree uncle :wink:

(='.'=)
OK, I get it, sister! :D

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by [-hh] » Thu Jul 06, 2017 2:17 am

@Klaus.

Sister? Or rather niece?
shiftLock happens

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Klaus » Thu Jul 06, 2017 2:56 pm

"Sister", Herman, since I was referring to Marias last posting:
... In a world where we are all sisters and brothers ...
:D

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by [-hh] » Thu Jul 06, 2017 3:15 pm

Oh I see, you won't be an uncle ...
shiftLock happens

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Tic tac, tic tac........ but less two tic? (='.'=)

Post by Klaus » Thu Jul 06, 2017 3:18 pm

[-hh] wrote:Oh I see, you won't be an uncle ...
Exactly, that's Bob already! :D

Post Reply