Count down date

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

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: Count down date

Post by croivo » Wed Jul 02, 2014 3:35 pm

That's right.

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

Re: Count down date

Post by [-hh] » Wed Jul 02, 2014 4:49 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:17 pm, edited 1 time in total.
shiftLock happens

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: Count down date

Post by croivo » Wed Jul 02, 2014 5:29 pm

Yea, go Germany!

I know how to make that kind of countdown, that's not problem, here is what I want: Current time is 18:28. My 'event' starts at 20:00. So the clock should start counting down like this: '01:31:50' until it gets to 00:00:00. I hope it's more clear now...

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

Re: Count down date

Post by [-hh] » Wed Jul 02, 2014 8:01 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:17 pm, edited 1 time in total.
shiftLock happens

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: Count down date

Post by croivo » Wed Jul 02, 2014 8:41 pm

I tried already something like that, now it almost work... here is the code:

Code: Select all

on mouseUp
   --CURRENT TIME CONVERT TO SECONDS
   put long system time into field "CURRENT"
   put field "CURRENT" into ctime
   
   set itemDel to colon
   put item 1 of ctime into chours
   put item 2 of ctime into cminutes
   put item 3 of ctime into cseconds
   --Multiply hours by 60 minutes
   multiply chours by 60
   --Multiply 60 minutes by 60 seconds
   multiply chours by 60
   --Multiply minutes by 60 seconds
   multiply cminutes by 60
   --ADD ALL:
   add cseconds to chours
   add cminutes to chours
   
   --FINAL TIME CONVERT TO SECONDS
   put field "FINAL" into ftime
   set itemDel to colon
   put item 1 of ftime into fhours
   put item 2 of ftime into fminutes
   put item 3 of ftime into fseconds   
   --Multiply hours by 60 seconds
   multiply fhours by 60
   --Multiply 60 minutes by 60 seconds
   multiply fhours by 60
   --Multiply minutes by 60 seconds
   multiply fminutes by 60
   --ADD ALL:
   add fseconds to fhours
   add fminutes to fhour
   
   --SUBTRACT
   subtract chours from fhours
   put fhours into HH
   divide HH by 3600
   --To be continued...
end mouseUp
So I have done both current and final time conversion to seconds successfully, but I don't know how to write this simple mathematics in LiveCode (I need ALWAYS to write this with text?!)
Now simply display every second the remaining seconds (= rst) as HH:MM:SS
HH = rst div 3600
MM = (rst - HH*3600) div 60
SS = rst mod 60
Btw I've tried to convert seconds to HH:MM:SS in more simple way by this

Code: Select all

convert fhours to long system time
but than I always get 1 spare hour...

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

Re: Count down date

Post by [-hh] » Wed Jul 02, 2014 9:42 pm

..........
Last edited by [-hh] on Wed Aug 13, 2014 3:17 pm, edited 1 time in total.
shiftLock happens

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: Count down date

Post by croivo » Thu Jul 03, 2014 12:03 pm

Yep that works... Only I need to subtract 2 from hours and that corrects them (I have no idea why there is 2 spare hours)... Anyway finished, thank you all for help!

Post Reply