| View previous topic :: View next topic |
| Author |
Message |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Fri Mar 13, 2009 9:11 am Post subject: bind time not working properly |
|
|
Hi, I have a script that uses bind time events.
It does something like this:
| Quote: |
[Fri-04:00:11am] * @RoBotX It is now: 04:00 AM. Uploading '/home/filipe/eggdrop/Triggers/triggerlog.txt' ««« 13/02/2009 »»»
|
See that? Everything is alright, but he says ««« 13/02/2009 »»», it should be 13/03/2009
What the hell is going on with months? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Mar 13, 2009 9:28 am Post subject: |
|
|
Show us the code so we can see how the date-string is being generated. Also, make sure the date is correctly set on the system where your Eggdrop is operating. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Fri Mar 13, 2009 4:14 pm Post subject: |
|
|
| Code: |
bind time - "00 04 * * *" prepareftp
proc prepareftp { minutes hour day month year } {
global lf ht us ps rf
sendftp $lf $ht $us $ps $rf
puthelp "PRIVMSG #cyber-world \001ACTION It is now: \002$hour:$minutes AM\002. Uploading '$lf' \002««« $day/$month/$year »»»\002"
}
|
|
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Mar 13, 2009 7:56 pm Post subject: |
|
|
Like in Java, the first month is 00 and not 01. So all you need to do is to add 1 to the $month variable.
| Code: | bind time - "00 04 * * *" prepareftp
proc prepareftp { minutes hour day month year } {
global lf ht us ps rf
sendftp $lf $ht $us $ps $rf
puthelp "PRIVMSG #cyber-world \001ACTION It is now: \002$hour:$minutes AM\002. Uploading '$lf' \002««« $day/[expr {$month + 1}]/$year »»»\002"
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Fri Mar 13, 2009 9:34 pm Post subject: |
|
|
Don't forget the 0-padding, making tcl think we're dealing with octals rather than integers. Simply using expr {$month + 1} won't work well, especially in September and October.
Something like this should take care of that though:
| Code: | | string trimleft $month "0" |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Fill Halfop
Joined: 18 Jan 2009 Posts: 80
|
Posted: Sat Mar 14, 2009 10:21 am Post subject: |
|
|
so how would it stay?
expr [[string trimleft $month "0"] +1] ?? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sat Mar 14, 2009 1:47 pm Post subject: |
|
|
Rather this:
expr {[string trimleft $month "0"] + 1} _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|