localtime and TZ

Ken Brown kbrown@cornell.edu
Sat Oct 30 19:25:00 GMT 2010


On 10/30/2010 8:58 AM, Ken Brown wrote:
>> I've looked at Cygwin's localtime.cc, and the behavior I'm complaining
>> about is caused by the following code at the beginning of tzset:
>>
>> 	const char *	name = getenv("TZ");
>>
>> 	if (name == NULL) {
>> 		if (!lcl_is_set)
>> 			tzsetwall();
>> 		goto out;
>> 	}
>>
>> So getting rid of 'if (!lcl_is_set)' would solve the problem.  But this
>> would be inefficient, because it would mean that tzsetwall gets called
>> every time tzset is called if TZ is never set.  To get around that, one
>> could have tzsetwall set TZ.
>>
>> It seems that tzset and tzsetwall used to behave the way I'm proposing
>> before the following two changes were made:
>>
>> 2007-12-11  Corinna Vinschen<corinna@vinschen.de>
>>
>> 	* localtime.cc (tzset): Call tzsetwall only if it hasn't been
>> 	called before.
>>
>> 2007-08-01  Corinna Vinschen<corinna@vinschen.de>
>>
>> 	* localtime.cc (tzsetwall): Don't set TZ.
>
> I've just found the reason for the 2007-08-01 change:
>
>     http://www.cygwin.com/ml/cygwin/2007-08/msg00041.html
>
> So I don't know what should be done.

How's the attached patch?  I'm not set up to build cygwin1.dll, so I 
can't test it right now.  I hope the intent is clear in case I got 
something wrong.

Ken
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tzset.patch
URL: <http://cygwin.com/pipermail/cygwin/attachments/20101030/ab010239/attachment.ksh>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list