|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Jun 01, 2005 1:18 pm
Difference between two times |
I've made a stopwatch of sorts which works, but seems a horribly convoluted way of doing it.
Glancing at the current alias below, is there a simple function I'm missing?
there are variables time1 and time2 that hold values taken using the %secs command, then timeDiff that does the following:
Code: |
#VARIABLE timeDiff {%abs( %eval( @time2 - @time1))} "Utils|timeDiff"
#IF (%round( %eval( %left( @timeDiff, %len( @timeDiff)-3)/60)) = 0) {#SAY %eval( %left( @timeDiff, %len( @timeDiff)-3) - %eval( 60*%round( %eval( %left( @timeDiff, %len( @timeDiff)-3)/60)))).%eval( %rightback( @timeDiff, 3)/100) seconds} {#SAY %round( %eval( %left( @timeDiff, %len( @timeDiff)-3)/60)) minutes, %eval( %left( @timeDiff, %len( @timeDiff)-3) - %eval( 60*%round( %eval( %left( @timeDiff, %len( @timeDiff)-3)/60)))).%eval( %rightback( @timeDiff, 3)/100) seconds} |
basically it snips the last 3 digits off the timediff and uses those for the milliseconds (rounding them to hundredths), then it splits the seconds into minutes and seconds and displays output either
'x.y seconds' (if there are 0 minutes) or 'z minutes, x.y seconds'
Not especially important, just thinking I've missed something.
Guinn |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Fri Jun 03, 2005 11:43 pm |
how about including a test feature to make sure it is working?
|
|
_________________ megamog75
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Sat Jun 04, 2005 10:08 pm |
oh, it works fine. just seems a long winded way of doing a simple thing
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Sun Jun 05, 2005 2:32 am |
to be for sure there is a shorter way, but why mess with what works.
%format and %time could probably do wonders for it. |
|
_________________ megamog75
I will do this.Nothing in my life matters except this.No moment in my life exists except this moment.I am born in this moment, and if I fail, I will die in this moment. Raistlin Majere |
|
|
|
|
|