time calculation - is there a better/easyer way? - 11/06/06 03:11 PM
Hey
im redoing my TeeTimer addon atm, and want to build in the function to activate at a specific clock aswell. Now for that i need a function to calculate how many seconds there are until that specific clock, until now i came up with this one and it works as supposed to, but is there maybe a simpler way?
im sure there is ... i have always been bad to the things that include $ctime and $asctime etc...
im redoing my TeeTimer addon atm, and want to build in the function to activate at a specific clock aswell. Now for that i need a function to calculate how many seconds there are until that specific clock, until now i came up with this one and it works as supposed to, but is there maybe a simpler way?
im sure there is ... i have always been bad to the things that include $ctime and $asctime etc...
Code:
;Usage: //echo -a $teetimerV2.timeuntil(13:00) ;Would calculate the amount of seconds until its 13 o'clock next time. ALIAS teetimerV2.timeuntil { var %then = $1 var %fixmins = $iif($gettok(%then,2,58) == 00,60,$v1) var %fixhour = $iif($gettok(%then,1,58) == 00,24,$v1) tokenize 32 $asctime(HH nn ss) var %secs = $calc(60 - $3) var %mins = $calc(%fixmins - ($2 +1)) var %hour = $calc(%fixhour - ($1 +1)) if (- isin %hour) set %hour $calc(24 %hour) ;echo -s Then: %then FixMins: %fixmins FixHour: %fixhour var %minssecs = $calc(%mins *60) var %hoursecs = $calc(%hour *3600) var %totalsecs = $calc(%hoursecs + %minssecs + %secs) return %totalsecs ;echo -s Hour: %hour -- Mins: %mins -- Secs: %secs ----- Total secs: %totalsecs }