| View previous topic :: View next topic |
| Author |
Message |
retan Voice
Joined: 11 Jun 2007 Posts: 5
|
Posted: Sat Jul 21, 2007 9:55 am Post subject: Compare two date/time Strings |
|
|
Hello
I have a date/time string like this: 30.12.2006 and 10:12:53
I want that this string is compared with the UNIX time (the time of the server where the eggdrop is running) and the difference to be outputted in this format:
xx years xx months xx days xx hours xx minutes xx seconds
How can I do that?
Thanks! |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Jul 21, 2007 10:19 am Post subject: |
|
|
First off, you'd have to convert that into something usable with clock scan.
Once you've converted it to an integer clock value (unixtime), use expr to calculate the diff (current time can be obtained from clock seconds), and use the eggdrop-speciffic command duration to format the output into something human-readable.
I'd probably do it something like this:
| Code: | proc timediff {date time} {
set t [split $date "."]
return [duration [expr [clock seconds] - [clock scan "[lindex $t 2][lindex $t 1][lindex $t 0]T${time}"]]]
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|