Page 1 of 1
Time elapsed function
Posted: Mon May 11, 2009 11:38 am
by barry.marcus
I'm a little confused by date math in Vortex. I'm attempting to create a function that will display in "hh:mm:ss" format the time elapsed between the time passed to the function and the time that the function is called (i.e., "now"). In other words, if it is, say, 12:05 PM when the function is called, and "11:55 AM" is passed to the function, I would like the function to return "10:00:00"
Thanks for your help.
Time elapsed function
Posted: Mon May 11, 2009 11:53 am
by mark
<$seconds=( convert( 'now' , 'date' )-$starttime)>
<$minutes=($seconds/60)>
<$seconds=($seconds-($minutes*60))>
<fmt "%02d:%02d" $minutes $seconds>
Or you might be interested in <sysinfo proctime>
Time elapsed function
Posted: Mon May 11, 2009 12:16 pm
by John
You may also want to check out the "reltime" function in Webinator that displays the difference in two times in a friendly fashion, e.g. "3 days 2 hours ago" or "4 hours 24 minutes ago". It doesn't go into too much precision for larger time periods.
Time elapsed function
Posted: Mon May 11, 2009 2:17 pm
by barry.marcus
Hmm. The line
<$seconds=(convert('now', 'date')-$startTime)>
gives me the error "Missing start single quote in value"
Time elapsed function
Posted: Mon May 11, 2009 2:18 pm
by barry.marcus
Also, I tried using <sysinfo proctime>. It returns nothing but zeroes for me.
Time elapsed function
Posted: Mon May 11, 2009 2:54 pm
by mark
Put spaces around the quoted literals as in my example.
Time elapsed function
Posted: Mon May 11, 2009 2:58 pm
by mark
What's your texis version? This works for me:
proctime <sysinfo proctime><loop $ret>$ret </loop>
proctime <sysinfo proctime $ret><loop $ret>$ret </loop>
giving:
proctime 0.001999 0.003999 0.003662
proctime 0 0 0.000443
Time elapsed function
Posted: Mon May 11, 2009 7:22 pm
by barry.marcus
Thanks, Mark.