tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* BUG: 4.0F/4.0G Libc tzset(3)
@ 2001-03-27 15:00 Arrigo Triulzi
  0 siblings, 0 replies; only message in thread
From: Arrigo Triulzi @ 2001-03-27 15:00 UTC (permalink / raw)
  To: tru64-unix-managers

Dear all,

there appears to be a bug in the libc definition of tzset(), both
under 4.0F (PK#2 + NHDv3) and 4.0G (PK#2).

According to the documentation for tzset(3) [man 3 tzset]:
``
  The external variable timezone is set to the difference, in seconds,
  between Coordinated Universal Time (UTC) and local standard time.  For
  example:
                                TZ    timezone
                                EST   5*60*60
                                GMT   0*60*60
                                JST   -9*60*60
                                MET   -1*60*60
                                MST   7*60*60
                                PST   8*60*60
''

This does not appear to be the case:

/* tzset-test.c */
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

main()
{
    char *timezone="TZ=GMT0";

    putenv(timezone);
    tzset();
    printf("daylight=%d\ntimezone=%ld\ntzname[0]=%s\ntzname[1]=%s\n",
           daylight, timezone,
           (tzname[0] ? tzname[0] : "NULL"),
           (tzname[1] ? tzname[0] : "NULL"));
    exit(0);
}

terracotta:/tmp$ ./tzset-test 
daylight=0
timezone=5368709312
tzname[0]=GMT
tzname[1]=GMT

The timezone value should be 0 according to the man page.  The
remaining values are correct.  Linux appears to have the same problem.

umbra:/tmp$ ./tzset-test 
daylight=0
timezone=134514176
tzname[0]=GMT
tzname[1]=GMT

Does this mean that the timezone variable should not be trusted?

Best Regards,

Arrigo Triulzi

-- 
Arrigo Triulzi <arrigo@albourne.com>
Albourne Partners Ltd. - London, UK

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-03-27 15:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-03-27 15:00 BUG: 4.0F/4.0G Libc tzset(3) Arrigo Triulzi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox