Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: 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
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Fri Jun 03, 2005 11:43 pm   
 
how about including a test feature to make sure it is working?
_________________
megamog75 Smile
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
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: 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... ;)
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: 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 Smile
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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net