This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Eggdrop BUG in bind time?

General support and discussion of Eggdrop bots.
Post Reply
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Eggdrop BUG in bind time?

Post by cerberus_gr »

Just look the following code and correct me if I'm wrong.

_geo_ is me and CerberuS is my eggdrop (1.6.17)

Code: Select all

[07:09:44] <_geo_> .tcl proc chktime { min hour day month year } { putlog "$min - $hour - $day - $month - $year" }
[07:09:44] <CerberuS> Tcl: 
[07:12:02] <_geo_> .tcl putlog [clock format [clock seconds] -format "%c"]
[07:12:02] <CerberuS> [07:11:29] Sat 19 Mar 2005 07:11:29 AM EET 
[07:12:03] <CerberuS> Tcl: 
[07:12:26] <_geo_> .tcl bind time - "12 07 * * *" chktime 
[07:12:26] <CerberuS> Tcl: 12 07 * * *
[07:12:33] <CerberuS> [07:12:00] 12 - 07 - 19 - 02 - 2005

Also date command for my shell is:

Code: Select all

-bash-2.05b$ date
Sat Mar 19 07:16:13 EET 2005

As you can see the month is March, which is 3rd, but when the time bind calls the chktime procedure the month which returns is 02.
Why this happens?

Thx :)
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

this is not a bug

eggdrop gets the time via standard library time functions, which utilize struct tm; that struct has the following members:

Code: Select all

           int tm_sec;     /* seconds (0 - 60) */
           int tm_min;     /* minutes (0 - 59) */
           int tm_hour;    /* hours (0 - 23) */
           int tm_mday;    /* day of month (1 - 31) */
           int tm_mon;     /* month of year (0 - 11) */
           int tm_year;    /* year - 1900 */
           int tm_wday;    /* day of week (Sunday = 0) */
           int tm_yday;    /* day of year (0 - 365) */
           int tm_isdst;   /* is summer time in effect? */
           char *tm_zone;  /* abbreviation of timezone name */
           long tm_gmtoff; /* offset from UTC in seconds */
as you can see, months are zero-base indexed
c
cerberus_gr
Halfop
Posts: 97
Joined: Fri Feb 07, 2003 8:57 am
Location: 127.0.0.1

Post by cerberus_gr »

Hmmm, I didn't know that!!! :oops: :oops: :oops:

So, if if I want to get the "real" number of month i have to [expr {$month + 1}].

Thx :)
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

demond wrote:this is not a bug

eggdrop gets the time via standard library time functions, which utilize struct tm; that struct has the following members:

Code: Select all

           int tm_sec;     /* seconds (0 - 60) */
           int tm_min;     /* minutes (0 - 59) */
           int tm_hour;    /* hours (0 - 23) */
           int tm_mday;    /* day of month (1 - 31) */
           int tm_mon;     /* month of year (0 - 11) */
           int tm_year;    /* year - 1900 */
           int tm_wday;    /* day of week (Sunday = 0) */
           int tm_yday;    /* day of year (0 - 365) */
           int tm_isdst;   /* is summer time in effect? */
           char *tm_zone;  /* abbreviation of timezone name */
           long tm_gmtoff; /* offset from UTC in seconds */
as you can see, months are zero-base indexed
::bump::

Maybe this should be noted in the tcl-command.doc, cos that file says digits are "exactly two-characterss long" :/
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

rosc2112 wrote: ::bump::

Maybe this should be noted in the tcl-command.doc, cos that file says digits are "exactly two-characterss long" :/
Eggdrop docs assume the user has the basic knowledge of unix-like operating systems to know that the first number in any count is 0.
With this knowledge, and the statement that digits require two characters, January is month 00.
Post Reply