There is a small bug in scli-0.2.8 in the code for converting time ticks relative to the current time into local time plus GMT offset.
The problem is that with
tm->tm_isdst = 0; mktime(tm);
the time struct in tm is modified by mktime, so that it represents the time with DST and tm_isdst is set, if DST is in effect at that time. This is done at least by glibc-2 and correct according to ISO 9899. That leads to the time in tm to be one hour ahead if DST is in effect:
isnogud:src$ echo show system info | scli localhost Name: isnogud Address: localhost:161 Description: Linux isnogud 2.4.18-ut #41 Wed Apr 3 23:28:01 CEST 2002 i686 Contact: Urs Thuermann urs@isnogud.escape.de Location: D-38106 Braunschweig, Germany Vendor: UCD-SNMP http://ucd-snmp.ucdavis.edu/ Current Time: 2002-05-02 08:55:58 +02:00 Agent Boot Time: 2002-05-02 09:04:37 +02:00 <--- [*] System Boot Time: 2002-04-24 21:51:10 +02:00 <--- [*] System Boot Args: auto BOOT_IMAGE=linux-2.4.18 ro root=100 ROOT=/dev/vg0/root Users: 3 Processes: 86 Memory: 250M Interfaces: 8 isnogud:src$ TZ= ls -l /var/log/boot.msg -rw-r--r-- 1 root root 4335 Apr 24 18:51 /var/log/boot.msg ^^^^^ isnogud:src$ ps xau|grep ^root.*snmp root 31871 0.1 0.8 3092 2068 ? S 08:04 0:04 /usr/sbin/snmpd ^^^^^
[*] Theses time are one hour ahead. The same problem can be seen with other times, too.
The appended patch solves the problem.
urs
diff -ru scli-0.2.8/scli/fmt.c scli/scli/fmt.c --- scli-0.2.8/scli/fmt.c 2002-03-27 14:41:27.000000000 +0100 +++ scli/scli/fmt.c 2002-05-02 08:03:22.000000000 +0200 @@ -81,7 +81,7 @@ { static char buffer[80]; time_t now, gmt; - struct tm *tm; + struct tm *tm, now_tm; int gmt_offset;
now = time(NULL); @@ -99,13 +99,14 @@ gmt = mktime(tm);
tm = localtime(&now); + now_tm = *tm; tm->tm_isdst = 0; gmt_offset = mktime(tm) - gmt;
g_snprintf(buffer, sizeof(buffer), "%04d-%02d-%02d %02d:%02d:%02d %c%02d:%02d", - tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec, + now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, + now_tm.tm_hour, now_tm.tm_min, now_tm.tm_sec, gmt_offset >= 0 ? '+' : '-', (int) ABS(gmt_offset) / 3600, (int) (ABS(gmt_offset) / 60) % 60);