Subject: lib/577: mktime does not call tzset()
To: None <>
From: Brian D. Carlstrom <bdc@JOLT.MIT.EDU>
List: netbsd-bugs
Date: 11/16/1994 16:35:03
>Number:         577
>Category:       lib
>Synopsis:       mktime does not call tzset
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 16 16:35:02 1994
>Originator:     Brian D. Carlstrom
"MIT AI Lab	"
>Release:        1.0
System: NetBSD 1.0 NetBSD 1.0 (FNORD) #0: Fri Oct 21 15:03:57 EDT 1994 i386

In NetBSD's time package, the mktime() function does not call tzset()
before doing time conversion. This is required by POSIX. See Section 8.1.1,
lines 113-114.
/* Unless your current time zone is GMT, this program should print out
** two different numbers. If the numbers are the same, then mktime()
** is broken.
#include <time.h>
#include <stdio.h>

extern char **environ;

  time_t t, t1;
  struct tm d;

  d = *localtime(&t);

  printf("%d time, offset %d %s\n", t, d.tm_gmtoff, d.tm_zone);

  /* Here, we reinterpret the time as GMT by temporarily setting $TZ to
  ** "TZ=UCT0" and passing the date to mktime().
  { char *newenv[2],
    **oldenv = environ;
    newenv[0] = "TZ=UCT0"; newenv[1] = 0;
#ifdef LOSE
    tzset();                    /* Remove this, and the program won't work. */
    t1 = mktime(&d);

  printf("%d UCT0 time\n", t1);


i'm just reporting this for someone else. no solution from me.
i suppose mktime can just call tzset but there might be something
better to do in the library...