Subject: lib/10282: localtime_r doesn't setup the time zone
To: None <gnats-bugs@gnats.netbsd.org>
From: Hal Murray <murray@pa.dec.com>
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
>Closed-Date:
>Last-Modified:
>Originator: Hal Murray
>Release: Jason's 1.4Z snapshot 27-May
>Organization:
Compaq - Systems Research Center
>Environment:
I've seen it on both Intel and Alpha.
>Description:
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
>How-To-Repeat:
#include <stdio.h>
#include <time.h>
#define DATELENGTH 100
int main (int argc, char *argv[])
{
time_t nowbin;
struct tm tm1, *tm2, tm3;
char ts1[DATELENGTH], ts2[DATELENGTH], ts3[DATELENGTH];
time(&nowbin);
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("Hi\n");
printf("tm1 => %s\n", ts1);
printf("tm2 => %s\n", ts2);
printf("tm3 => %s\n", ts2);
printf("\n");
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
>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