| View previous topic :: View next topic |
| Author |
Message |
uHost Voice
Joined: 20 Aug 2009 Posts: 2
|
Posted: Thu Aug 20, 2009 2:29 pm Post subject: calculating time |
|
|
Hello.
can anyone help with a script?
I need a script calculating time in minutes. For exemple:
18:55 20/08/2009 >> Today
<uHost> !time 10
<Eggie> 19:05 20/08/2009
<uHost> !time 1440
<Eggie> 18:55 21/08/2009
I think you can understand me.  |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
Posted: Thu Aug 20, 2009 2:47 pm Post subject: |
|
|
| Code: | # tomekk, http://forum.egghelp.org/viewtopic.php?t=17119
bind pub -|- !time make_time
proc make_time { nick uhost hand chan arg } {
set arg [lindex [split $arg] 0]
if {[regexp {^[0-9]+$} $arg]} {
set cdate [clock format [expr [clock seconds] + [expr $arg * 60]] -format "%H:%M %d/%m/%Y"]
putquick "PRIVMSG $chan :$cdate"
}
}
putlog "make-time.tcl ver 0.1 by tomekk loaded"
|
try, didn't test ;p |
|
| Back to top |
|
 |
uHost Voice
Joined: 20 Aug 2009 Posts: 2
|
Posted: Thu Aug 20, 2009 4:28 pm Post subject: |
|
|
Hehe
It works, but has a bug. I can't use more than 9 numbers.
<uHost> !time 12345678
<Eggie> 06:41 09/02/2033
<uHost> !time 123456789
<Eggie> 05:35 01/03/1972
Thanks  |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Thu Aug 20, 2009 4:47 pm Post subject: |
|
|
The value of the supplied argument is too high and the result of the expr command has wrapped to a negative integer value. Hence, instead of adding to [clock seconds] which results in a future time string, it has been deducted from [clock seconds] which has given a past time string. It is not so much a bug, more of a limitation. _________________ I must have had nothing to do |
|
| Back to top |
|
 |
|