This is the mail archive of the libc-alpha@cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

timezone bug?



Ian has send the following bug report.  I can reproduce the behaviour
with glibc 2.1.

Can anybody look into it and tell us whether this is a bug in glibc or
expected behaviour?

Thanks,
Andreas 

------- start of forwarded message (RFC 934 encapsulation) -------
From: Ian Collier <Ian.Collier@comlab.ox.ac.uk>
To: bugs@gnu.org
Subject: libc/1054: global var "timezone" incorrect in GB zone
Date: Mon, 29 Mar 1999 23:34:41 +0100


>Number:         1054
>Category:       libc
>Synopsis:       global var "timezone" shows DST instead of standard time when TZ=GB
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Mon Mar 29 17:40:01 EST 1999
>Last-Modified:
>Originator:     Ian Collier
>Organization:
 Oxford University Computing Laboratory
>Release:        libc-2.0.7
>Environment:
	Red Hat Linux 5.1 with updates, glibc-2.0.7-29.i386.rpm
Host type: i686-pc-linux-gnu
System: Linux starbright 2.0.36 #4 Sun Feb 7 13:32:09 GMT 1999 i586 unknown
Architecture: i586

Addons: crypt linuxthreads localedata
Build CFLAGS: -O2 -m486 -fno-strength-reduce -g -DNDEBUG=1
Build CC: gcc -B$(common-objpfx)
Build shared: yes
Build profile: yes
Build omitfp: no
Stdio: libio

>Description:
	The man page for localtime(3) states that the external variable
	timezone is set with the difference between UTC and local standard
	time in seconds (the info file for libc seems to agree but in more
	cryptic wording), but in the GB zone it appears to set timezone to
	-3600 which is local daylight time, not local standard time.  This
	was observed both before and after the DST change on 28-Mar-1999.
	Some other zones such as NZ also produce odd results.
>How-To-Repeat:
$ cat timezone.c
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
main() {
   struct tm *tp;
   struct timeval tv;
   gettimeofday(&tv,NULL);
   tp=localtime(&tv.tv_sec);
   printf("%d %d %d\n",(int)tp->tm_gmtoff,(int)tp->tm_isdst,(int)timezone);
   exit(0);
}
$ gcc timezone.c
$ date
Mon Mar 29 23:27:01 BST 1999
$ TZ=GB ./a.out
3600 1 -3600
# (it's dst and the local offset is 3600 seconds, but the timezone variable
# should be 0 not -3600 since the doc says it is not DST-adjusted)
$ TZ=BST-1 ./a.out
3600 0 -3600
# (correct)
$ TZ=CET ./a.out
7200 1 -3600
# (correct, DST is -7200 so standard would be -3600)
$ TZ=EST5EDT ./a.out
- -18000 0 18000
# (correct)
$ TZ=EST ./a.out
- -18000 0 21600
# (incorrect - the difference is never 6 hours even in DST)
$ TZ=NZ ./a.out
43200 0 -41400
# (I don't understand this answer)
>Fix:
>Audit-Trail:
>Unformatted:
------- end -------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]