|
JWhitney Wanderer
Joined: 20 Oct 2006 Posts: 51
|
Posted: Sun Oct 23, 2011 12:31 pm
Figuring Out Future Time |
I am struggling to come up with a way to figure out what date/time it will be after a varying amount of time.
Example output from MUD:
Code: |
Armageddon will arrive in 1d 12h 8m 58s |
I would like to #SUB in what date/time it will be, like this:
Code: |
Armageddon will arrive in 1d 12h 8m 58s (Oct 24th 7:45PM) |
..or something similar. Doesn't SEEM like it should be that difficult, but I'm probably over-thinking it. Is there an easy way to do this?
Thank you for your time. |
|
|
|
geniusclown Magician
Joined: 23 Apr 2003 Posts: 358 Location: USA
|
Posted: Sun Oct 23, 2011 1:53 pm |
The current time on your computer's clock is accessible via the %time function, which can report just the minute or the second, etc. There's a few ways you can work with this, here's one that adds and carries (took a shortcut on the day because it's much more complicated if the timer crosses one month to the next - would have to consider how many days in the month, etc):
Code: |
#TR {^(Armageddon will arrive in %s(%d)d (%d)h (%d)m (%d)s)} {
$day=%2
$hour=(%time(h)+%3)
$min=(%time(n)+%4)
$sec=(%time(s)+%5)
#IF ($sec>59) {$sec=($sec-60);$min=($min+1)}
#IF ($min>59) {$min=($min-60);$hour=($hour+1)}
#IF ($hour>23) {$hour=($hour-24);$day=($day+1)}
#SUB {%1, at %if($hour>12,($hour-12),$hour)~:%if($min<10,0)$min~:%if($sec<10,0)$sec %if($hour>12,pm,am) %if($day=1,tomorrow,$day days from now).}
} |
|
|
_________________ .geniusclown |
|
|
|
JWhitney Wanderer
Joined: 20 Oct 2006 Posts: 51
|
Posted: Mon Oct 24, 2011 6:35 am |
That works great, thank you!
|
|
|
|
|
|
|
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
|
|