Subject: lib/10282: localtime_r doesn't setup the time zone
To: None <>
From: Hal Murray <>
List: netbsd-bugs
Date: 06/05/2000 01:27:11
>Number:         10282
>Category:       lib
>Synopsis:       localtime_r doesn't setup the time zone
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 05 01:28:00 PDT 2000
>Originator:     Hal Murray
>Release:        Jason's 1.4Z snapshot 27-May
        Compaq - Systems Research Center
        I've seen it on both Intel and Alpha.
  Looks like localtime_r doesn't setup the time zone correctly.
  localtime (no _r) does, and after than localtime_r gets the
  right answer.

  Here are 3 lines of printout that should be the same.  The first 
  and last are from localtime_r.  The middle one is from localtime.

tm1 => 2000-Jun-05 08:15 <= I'm in PDT
tm2 => 2000-Jun-05 01:15
tm3 => 2000-Jun-05 01:15


#include <stdio.h>
#include <time.h>
#define DATELENGTH 100

int main (int argc, char *argv[])
  time_t nowbin;
  struct tm tm1, *tm2, tm3;
  localtime_r(&nowbin, &tm1);
  tm2 = localtime(&nowbin);
  localtime_r(&nowbin, &tm3);

  strftime(ts1, DATELENGTH, "%Y-%b-%d %H:%M", &tm1);
  strftime(ts2, DATELENGTH, "%Y-%b-%d %H:%M", tm2);
  strftime(ts3, DATELENGTH, "%Y-%b-%d %H:%M", &tm3);

  printf("tm1 => %s\n", ts1);
  printf("tm2 => %s\n", ts2);
  printf("tm3 => %s\n", ts2);
  return 0;


 >System: NetBSD hgm80y 1.4Z NetBSD 1.4Z (PC5133) #0: Mon May 29 18:30:57 PDT 2000
  murray@hgm80y:/usr/src/sys/arch/i386/compile/PC5133 i386