This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: localtime and TZ

On 10/29/2010 6:16 PM, Eric Blake wrote:
On 10/29/2010 04:11 PM, Ken Brown wrote:

Thanks, Eric. I didn't know about any of this. (I was using a modification of a configure test from the emacs sources.)

Probably worth pointing it out to the emacs upstream, then :)

But I get the same behavior with the following revised test case:


main (void)
   time_t now = time ((time_t *) 0);
   printf ("TZ is initially unset; hour = %d\n", localtime (&now)->tm_hour);
   putenv ("TZ=GMT0");
   printf ("TZ=GMT0; hour = %d\n", localtime (&now)->tm_hour);
   printf ("TZ unset; hour = %d\n", localtime (&now)->tm_hour);
   putenv ("TZ=PST8");
   printf ("TZ=PST8; hour = %d\n", localtime (&now)->tm_hour);
   printf ("TZ unset again; hour = %d\n", localtime (&now)->tm_hour);

So the question remains whether this difference between Cygwin and Linux is a bug or by design.

Apparently by design. POSIX requires:

Local timezone information is used as though localtime() calls tzset().

The tzset() function shall use the value of the environment variable TZ
to set time conversion information used by ctime , localtime , mktime ,
and strftime . If TZ is absent from the environment,
implementation-defined default timezone information shall be used.

Wouldn't you interpret this as meaning that the implementation-defined default timezone information should be the same every time localtime is called with TZ unset? If not, what should a program do to get the "standard" default timezone information that it would get if TZ had never been set in the first place?


Problem reports:
Unsubscribe info:

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