This is the mail archive of the
libc-hacker@sourceware.cygnus.com
mailing list for the glibc project.
Bug in timezone setting (PR libc/776)
- To: libc-hacker@cygnus.com
- Subject: Bug in timezone setting (PR libc/776)
- From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
- Date: 10 Sep 1998 23:50:33 +0900
- Mail-Copies-To: never
PR libc/776 describes a situation where the timezone variable isn't
set. I'm including the test program (called timezone) from the
report, some comments and a patch for timezone/tst-timezone.c which
adds this test. I'm not adding a fix for the bug - but hope somebody
else does.
$ ll /etc/localtime
lrwxrwxrwx 1 root root 33 May 24 15:02 /etc/localtime -> /usr/share/zoneinfo/Europe/Berlin
$ ./timezone
Thu Sep 10 16:42:01 1998
CET CEST
-3600 7200
Everything ok.
$ TZ=Asia/Tokyo ./timezone
Thu Sep 10 23:49:09 1998
JST JST
0 32400
Why is timezone == 0? It should be -32400.
$ TZ=JST-9 ./timezone
Thu Sep 10 23:49:18 1998
JST JST
-32400 32400
Ok, this works - timezone is set correctly.
The bug is in glibc 2.1 and glibc 2.0.7 current.
Andreas
#include <stdio.h>
#include <time.h>
int main(int argc, char *argv[])
{
time_t t;
struct tm *tm;
int i;
tzset();
t = time(NULL);
tm = localtime(&t);
printf("%s", asctime(tm));
printf("%s %s\n", tzname[0], tzname[1]);
printf("%d %d\n", timezone, tm->tm_gmtoff);
return 0;
}
1998-09-10 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* timezone/tst-timezone.c (tests): Add test for Asia/Tokyo (see PR
libc/776).
--- timezone/tst-timezone.c.~1~ Sat Jul 4 23:29:51 1998
+++ timezone/tst-timezone.c Thu Sep 10 16:46:10 1998
@@ -40,6 +40,7 @@
{ "Australia/Melbourne", 1, -36000, { "EST", "EST" }},
{ "America/Sao_Paulo", 1, 10800, {"EST", "EDT" }},
{ "America/Los_Angeles", 1, 28800, {"PST", "PDT" }},
+ { "Asia/Tokyo", 0, 32400, {"JST", "JST" }},
{ NULL, 0, 0 }
};
--
Andreas Jaeger aj@arthur.rhein-neckar.de jaeger@informatik.uni-kl.de
for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de