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: Time zone bug


On 2017-05-01 09:25, cyg Simple wrote:
> On 4/30/2017 7:19 PM, Steven Penny wrote:
>> On Sun, 30 Apr 2017 17:37:00, Ken Brown wrote:
>>> As a result of a failing emacs test, I came across the following:
>>>
>>> $ TZ='NZST-12NZDT,M9.5.0,M4.1.0/3' date -d@0 +'%Y-%m-%d %H:%M:%S %z (%Z)'
>>> 1970-01-01 12:00:00 +1200 (NZST)
>>>
>>> The same command on Linux yields "1970-01-01 13:00:00 +1300 (NZDT)",
>>> which is
>>> correct according to Paul Eggert
>>> (https://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00881.html).

This may be a problem in: 

	winsup/cygwin/localtime.cc

not properly handling POSIX time zone specs in the S hemisphere, with DST 
which starts in autumn/fall and ends in spring, at the start of the time_t 
epoch, where the first DST transition happens with negative time_t. 

Neither localtime nor mktime on Cygwin properly handle these rules where 
both localtime and mktime on Linux do - STC and sdiff attached. 

On Linux, even if you comment out the localtime call, mktime sets the 
offset correctly; on Cygwin even using localtime and mktime fails to set 
the offset at 1970-01-01 correctly. 

Cygwin awk strftime also shows the same issue where Linux is also correct.

>> I concur, here is non-esoteric example Linux:
>>    $ TZ=Pacific/Auckland date +%Z
>>    NZST
>>    $ TZ=NZST date +%Z
>>    NZST
>>    $ TZ=NZDT date +%Z
>>    NZDT
>> Cygwin:
>>    $ TZ=Pacific/Auckland date +%Z
>>    NZST
>>    $ TZ=NZST date +%Z
>>    GMT
>>    $ TZ=NZDT date +%Z
>>    GMT

This is just a slight difference in handling POSIX time zone specs 
with no explicit offset specified - the basic format is std offset. 
If you provide only a std abbr with no offset, Cygwin defaults to 
GMT, where Linux uses the abbr and sets the offset to zero. Both 
behave identically if you specify a +-offset:

$ TZ=XXX date +"%F %a %R%z(%Z)"; TZ=XXX0 date +"%F %a %R%z(%Z)"
2017-05-01 Mon 17:13+0000(GMT)
2017-05-01 Mon 17:13+0000(XXX)
$ ssh ... 'TZ=XXX date +"%F %a %R%z(%Z)"; TZ=XXX0 date +"%F %a %R%z(%Z)"'
2017-05-01 Mon 17:13+0000(XXX)
2017-05-01 Mon 17:13+0000(XXX)

depends whether you prefer to see the same answer or the smart answer ;^>

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

Attachment: local-mktime-z-stc-diff.txt
Description: Text document

Attachment: local-mktime-z-stc.c
Description: Text document

--
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

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