Mail Archives: cygwin/2021/06/12/12:35:16
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-Original-To: | cygwin AT cygwin DOT com
|
Delivered-To: | cygwin AT cygwin DOT com
|
DMARC-Filter: | OpenDMARC Filter v1.4.1 sourceware.org 8C67B3858023
|
Authentication-Results: | sourceware.org; dmarc=none (p=none dis=none)
|
| header.from=SystematicSw.ab.ca
|
Authentication-Results: | sourceware.org;
|
| spf=none smtp.mailfrom=systematicsw.ab.ca
|
X-Authority-Analysis: | v=2.4 cv=H864f8Ui c=1 sm=1 tr=0 ts=60c4e22e
|
| a=T+ovY1NZ+FAi/xYICV7Bgg==:117 a=T+ovY1NZ+FAi/xYICV7Bgg==:17
|
| a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=w_pzkKWiAAAA:8 a=yMhMjlubAAAA:8
|
| a=uZvujYp8AAAA:8 a=CCpqsmhAAAAA:8 a=uPZiAMpXAAAA:8 a=bcK2PKoGsawsbSr0l2oA:9
|
| a=QEXdDO2ut3YA:10 a=otTE43H4AhkA:10 a=AomDDAB-fV4A:10 a=qH7zXGipjgEA:10
|
| a=d7cazv4TbHQA:10 a=sRI3_1zDfAgwuvI8zelB:22 a=SLzB8X_8jTLwj6mN0q5r:22
|
| a=ul9cdbp4aOFLsgKbc677:22
|
To: | cygwin AT cygwin DOT com
|
References: | <CAAHpriO6A+6bLXt0Qe-xpdXT1CiLjk7=7G31cHBtnVJ0kXb2Eg AT mail DOT gmail DOT com>
|
| <CAAHpriOJ5EZ0YzXjNOV-fydCb6bWHmPKiFZUC7KtFAi8DnkkDQ AT mail DOT gmail DOT com>
|
| <02d5b40f-aa35-f56c-5c5c-b10780355e91 AT SystematicSw DOT ab DOT ca>
|
| <0fcfeb54-53c5-b83d-bb13-e83a68eed469 AT cornell DOT edu>
|
| <28d9253d-71f4-c265-2861-9a3b0667799b AT SystematicSw DOT ab DOT ca>
|
| <be106324-4371-a804-5ccc-dec22b37f4af AT cornell DOT edu>
|
| <de7f3163-74c0-f304-ee58-a12064864196 AT SystematicSw DOT ab DOT ca>
|
| <55e1f8cd-ae55-dbda-ea6e-b9c000ec329c AT cornell DOT edu>
|
From: | Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
|
Organization: | Systematic Software
|
Subject: | Re: Python for Windows reports wrong local time when run under Cygwin
|
| on Europe/Moscow TZ
|
Message-ID: | <2fbd2f7a-f08e-eb92-174e-f9380420c31d@SystematicSw.ab.ca>
|
Date: | Sat, 12 Jun 2021 10:34:52 -0600
|
User-Agent: | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
|
| Thunderbird/78.11.0
|
MIME-Version: | 1.0
|
In-Reply-To: | <55e1f8cd-ae55-dbda-ea6e-b9c000ec329c@cornell.edu>
|
X-CMAE-Envelope: | MS4xfAAMOWal+wU5Myvryti9uVOb8kRzxkSiCjl10lOCFmBA9X3yjob39soTHAoHmf2iByIUKf/S+PYWln/rwzwgyYYnsYwt12Fc6OBF9728OceOTbnWPPP8
|
| hCJy8Nt7+8h6idYWRDoHAi6G1fnhKKBAX0WGRdM1j6xYYrlq60cnUQ5/aXh4yqqk/RlXZSZFGaGpaO/RAq7f02ricx40cnMR8M0=
|
X-Spam-Status: | No, score=-3486.1 required=5.0 tests=BAYES_00, BODY_8BITS,
|
| KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_LOTSOFHASH, NICE_REPLY_A,
|
| RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE,
|
| TXREP autolearn=no autolearn_force=no version=3.4.2
|
X-Spam-Checker-Version: | SpamAssassin 3.4.2 (2018-09-13) on
|
| server2.sourceware.org
|
X-BeenThere: | cygwin AT cygwin DOT com
|
X-Mailman-Version: | 2.1.29
|
List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com>
|
List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>,
|
| <mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
|
List-Archive: | <https://cygwin.com/pipermail/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help>
|
List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>,
|
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
|
Reply-To: | cygwin AT cygwin DOT com
|
Errors-To: | cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
|
Sender: | "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
|
X-MIME-Autoconverted: | from base64 to 8bit by delorie.com id 15CGZGml016250
|
On 2021-06-11 12:05, Ken Brown via Cygwin wrote:
> On 6/11/2021 1:33 PM, Brian Inglis wrote:
>> On 2021-06-10 13:50, Ken Brown via Cygwin wrote:
>>> On 6/10/2021 2:31 PM, Brian Inglis wrote:
>>>> On 2021-06-10 08:57, Ken Brown via Cygwin wrote:
>>>>> On 6/9/2021 10:36 PM, Brian Inglis wrote:
>>>>>> On 2021-06-09 16:31, Keith Thompson via Cygwin wrote:
>>>>>>> [Sorry if the threading is messed up. I don't subscribe, so I'm
>>>>>>> constructing this message from the web interface. It should at
>>>>>>> least
>>>>>>> show up under the correct subject.]
>>>>>>>
>>>>>>> Brian Inglis wrote:
>>>>>>>> On 2021-06-08 14:03, Mike Kaganski via Cygwin wrote:
>>>>>>>>> On 08.06.2021 16:04, L A Walsh wrote:
>>>>>>>>>> You might ask on a python list if anyone else has experienced
>>>>>>>>>> something similar with python or any other program. I'm
>>>>>>>>>> fairly sure
>>>>>>>>>> that neither MS nor cygwin design their OS with python in mind
>>>>>>>>>> and
>>>>>>>>>> that it is python that is interacting funny when running under
>>>>>>>>>> some
>>>>>>>>>> merge of both. Have you asked the python people about this
>>>>>>>>>> problem?
>>>>>>>>>> What did they suggest?
>>>>>>>>>
>>>>>>>>> FTR: filed https://bugs.python.org/issue44352.
>>>>>>>>
>>>>>>>> See Keith Thompson subthread and my reply with suggested fix:
>>>>>>>>
>>>>>>>> https://cygwin.com/pipermail/cygwin/2021-June/248692.html
>>>>>>>>
>>>>>>>> Windows does not recognize zoneinfo time zone identifiers in TZ
>>>>>>>> only
>>>>>>>> base format POSIX TZ strings with three alphabetic character
>>>>>>>> identifiers:
>>>>>>>>
>>>>>>>> https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset?view=msvc-160
>>>>>>>>
>>>>>>>>
>>>>>>>> That assumes US switch date "rules": for all years up to
>>>>>>>> current, or
>>>>>>>> just DST, and whether pre- or post-2007 is unstated!
>>>>>>>>
>>>>>>>> Otherwise it defaults to regional settings, used by Cygwin to
>>>>>>>> map to
>>>>>>>> zoneinfo time zone identifiers, so if Python for Windows could
>>>>>>>> clear TZ
>>>>>>>> before it is read by MSVCRT, it should DTRT.
>>>>>>>>
>>>>>>>> Windows does not recognize expanded POSIX TZ format strings with <>
>>>>>>>> quoted alphanumeric characters, "-", "+", and start and end
>>>>>>>> dates/times:
>>>>>>>>
>>>>>>>> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#bottom
>>>>>>>>
>>>>>>>>
>>>>>>>> which make them usable outside of the US.
>>>>>>>
>>>>>>> Summary: IMHO Cygwin should adapt its default TZ setting to work
>>>>>>> with Windows.
>>>>>>>
>>>>>>> The suggestion is to modify Python for Windows so it can deal with
>>>>>>> the TZ format used by Cygwin. I haven't used Python for Windows,
>>>>>>> but
>>>>>>> as far as I know it's unrelated to Cygwin; rather it, like
>>>>>>> Cygwin, is
>>>>>>> intended to work on top of Windows. I'm not convinced it's
>>>>>>> appropriate
>>>>>>> to ask Python for Windows to make a change purely for the sake of
>>>>>>> interoperating with Cygwin, which many PfW users presumably aren't
>>>>>>> even using.
>>>>>>>
>>>>>>> I've run into another application that has problems with Cygwin's
>>>>>>> settings of $TZ. It was a internal test application that isn't
>>>>>>> going to change its timezone handling just for this problem.
>>>>>>>
>>>>>>> The ideal solution would be for Windows to recognize TZ values like
>>>>>>> "America/Los_Angeles", but that's not likely to happen any time
>>>>>>> soon.
>>>>>>>
>>>>>>> My suggestion, since Cygwin is supposed to interoperate with
>>>>>>> Windows,
>>>>>>> is one of the following:
>>>>>>>
>>>>>>> - Cygwin should avoid setting TZ to a value that Windows doesn't
>>>>>>> recognize
>>>>>>> Â Â (if I set TZ=PST8PDT, everything seems to work correctly); OR
>>>>>>>
>>>>>>> - Cygwin shouldn't set TZ at all by default. (I've updated my
>>>>>>> Â Â $HOME/.bash_profile on Cygwin to unset TZ, and Cygwin commands
>>>>>>> seem
>>>>>>> Â Â to work correctly with TZ unset); OR
>>>>>>>
>>>>>>> - Cygwin, when invoking a non-Cygwin executable, should first either
>>>>>>> Â Â unset TZ or translate it to a format that Windows will recognize.
>>>>>>> Â Â I have no idea how difficult that would be.
>>>>>>
>>>>>> Impossible to set Windows TZ usefully as it obeys unstated US DST
>>>>>> rules (like posixrules, perhaps 2007+?), and may have limits on
>>>>>> hour offset magnitudes.
>>>>>> MS libraries are stuck at POSIX 1996 and C 99 subset
>>>>>> compatibility, but non-standard-conformant including which headers
>>>>>> contain definitions:
>>>>>>
>>>>>> Â Â Â Â Â https://docs.microsoft.com/en-us/cpp/c-runtime-library/compatibility?view=msvc-160
>>>>>>
>>>>>>
>>>>>> It may be possible to unset TZ when running non-Cygwin programs
>>>>>> (possibly behind a CYGWIN env var setting e.g. winnotz) by adding
>>>>>> TZ= to conv_envvars, and writing new helper functions
>>>>>> env_tz_to_posix to call tzset and env_tz_to_win32 to remove TZ in:
>>>>>>
>>>>>> Â Â Â Â Â https://sourceware.org/git/?p=newlib-cygwin.git;f=winsup/cygwin/environ.cc;a=blob
>>>>>>
>>>>>>
>>>>>> What is the opinion on this from both Windows users and Cygwin
>>>>>> patchers?
>>>>>
>>>>> I'm not convinced it's worth the trouble. I haven't seen anyone
>>>>> argue that it's useful for Cygwin to set TZ, and I have seen an
>>>>> argument that it's harmful:
>>>>>
>>>>> Â Â https://cygwin.com/pipermail/cygwin/2017-May/232675.html .
>>>>>
>>>>> So I prefer Keith's second suggestion:
>>>>>
>>>>> Â >> - Cygwin shouldn't set TZ at all by default.
>>>>
>>>> It does so in default startup scripts
>>>
>>> Right, and I'm agreeing with Bruno (in the message cited above) that
>>> the default startup scripts should stop doing that.
>>>
>>>> to get the correct behaviour from Cygwin DLL and programs,
>>>
>>> Can you be more specific? What goes wrong if TZ is not set? I
>>> haven't seen any POSIX or Linux documentation that says it should be
>>> set, and I've just checked on two different Linux distros that it's
>>> not set by default.
See original message:
https://sourceware.org/pipermail/cygwin/2012-January/199548.html
Looks like the tzdb metadata is not fully populated, including zone
abbreviations, though that could be patched to use <%z> like tzdata
defaults where countries use only a single local time zone and no name
(other than COUNTRY time, and maybe Winter Time or Summer Time, as in
many European countries).
>> I would expect that date, ls, etc. would output UTC, or perhaps PST or
>> EST, depending on tzdata builds of Factory (tz -00/unset) and
>> posixrules (Cygwin PST, Debian EST) and use during system setup and
>> startup, unless /etc/timezone and/or /etc/localtime are set, and used
>> during startup, often by systemd, or login by profiles.
>
> No, you can 'unset TZ' and everything works fine. Try it yourself.
It works incorrectly before 2007 because of DST rule changes.
Cygwin effectively uses expanded POSIX rules with a single pair of
transition dates, applied to all years.
Doesn't work for anything other than current time rules, as Cygwin
doesn't (yet?) use historical "Dynamic" DST.
"Dynamic" DST was probably only added to Vista about 2006 because the US
was changing rules in 2007.
See comments by MS TZ/DST blogger, commentator, and tzdb contributor
Matt Johnson-Pint:
https://stackoverflow.com/questions/19838892/dynamic-dst-historical-data
where he suggest the poster uses tzdb instead of trying to fix Windows
Dynamic DST rules!
[I could generate equivalent Windows Dynamic DST reg entries from tzdb,
but tzdb allows relational holiday calendar rules like "May Mon<25" -
the Monday before the 25th May (Victoria Day, CA which mostly coincides
with Memorial Day, US), and generates up to 400 years of entries, which
I don't think the registry would cope with too well!]
For Windows TZ updates see:
https://support.microsoft.com/kb/914387
Support for rule changes from 2010:
http://support.microsoft.com/gp/cp_dst
As a result, it does not have much in the way of history for times past
(see links above and examples below), unlike the tzdb in tzdata package,
which has full history back to 1970, and in some cases, back to before
standard time (Local Mean Time); if you have the tzcode package
installed, try zdump with your local time zone e.g.:
$ zdump -Vc1800,2008 America/New_York
or use -Vc1800,2022 in other countries with more recent changes.
Many zones in the Middle East have up to four changes each year if DST
would be in effect during Ramadan (it is reverted temporarily during
that month), and there are many recent rule changes in most other
countries, even Europe where countries jumped around annually until they
joined or decided to conform with the EU, similar to Canadian provinces
and Mexican states deciding to conform with the US from 2007, although
some zones in both countries changed their minds after that, and some
dropped DST e.g. Yukon CA in 2020!)
From MS comments about Ramadan not appearing in TZ history, with the
implication that MS have kludged current timekeeping to handle a DST
reversion, but may be unable to handle more than one transition a year,
historical file timestamps from earlier in the year will be displayed
incorrectly.
MS are issuing historical corrections for previous years for Windows 10,
but it looks like earlier Windows versions are getting more outdated:
https://docs.microsoft.com/en-us/archive/blogs/dst2007/
https://techcommunity.microsoft.com/t5/Daylight-Saving-Time-Time-Zone/bg-p/DSTBlog
>> How do you set or get useful local time on your systems?
>
> Cygwin takes care of it. If TZ is unset, Cygwin queries Windows via
> GetTimeZoneInformation. See tzgetwintzi in
> winsup/cygwin/tzcode/localtime_wrapper.c.
I was asking about your Linux/BSD systems.
[Dump of Windows tz info for my tz (from Cygwin regtool as it converts
to decimal but does not dump REG_BINARY keys in full only the first
eight bytes, and Windows reg to dump REG_BINARY keys in full):
$ win-reg-tzi.sh
HKLM/SYSTEM/CurrentControlSet/Control/TimeZoneInformation
Bias (REG_DWORD) = 0x000001a4 (420)
DaylightBias (REG_DWORD) = 0xffffffc4 (4294967236)
DaylightName (REG_SZ) = "@tzres.dll,-191"
DaylightStart (REG_BINARY) = 00 00 03 00 02 00 02 00
DynamicDaylightTimeDisabled (REG_DWORD) = 0x00000000 (0)
RealTimeIsUniversal (REG_DWORD) = 0x00000001 (1)
StandardBias (REG_DWORD) = 0x00000000 (0)
StandardName (REG_SZ) = "@tzres.dll,-192"
StandardStart (REG_BINARY) = 00 00 0b 00 01 00 02 00
TimeZoneKeyName (REG_SZ) = "Mountain Standard Time"
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
Bias REG_DWORD 0x1a4
DaylightBias REG_DWORD 0xffffffc4
DaylightName REG_SZ @tzres.dll,-191
DaylightStart REG_BINARY 00000300020002000000000000000000
DynamicDaylightTimeDisabled REG_DWORD 0x0
RealTimeIsUniversal REG_DWORD 0x1
StandardBias REG_DWORD 0x0
StandardName REG_SZ @tzres.dll,-192
StandardStart REG_BINARY 00000B00010002000000000000000000
TimeZoneKeyName REG_SZ Mountain Standard Time
HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/Mountain
Standard Time
Dynamic DST\ ()
Display (REG_SZ) = "(UTC-07:00) Mountain Time (US & Canada)"
Dlt (REG_SZ) = "Mountain Summer Time"
MUI_Display (REG_SZ) = "@tzres.dll,-190"
MUI_Dlt (REG_SZ) = "@tzres.dll,-191"
MUI_Std (REG_SZ) = "@tzres.dll,-192"
Std (REG_SZ) = "Mountain Standard Time"
TZI (REG_BINARY) = a4 01 00 00 00 00 00 00
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones\Mountain Standard Time
Display REG_SZ (UTC-07:00) Mountain Time (US & Canada)
Dlt REG_SZ Mountain Summer Time
MUI_Display REG_SZ @tzres.dll,-190
MUI_Dlt REG_SZ @tzres.dll,-191
MUI_Std REG_SZ @tzres.dll,-192
Std REG_SZ Mountain Standard Time
TZI REG_BINARY
A401000000000000C4FFFFFF00000B0000000100020000000000000000000300000002000200000000000000
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones\Mountain Standard Time\Dynamic DST
2006 REG_BINARY
A401000000000000C4FFFFFF00000A0000000500020000000000000000000400000001000200000000000000
2007 REG_BINARY
A401000000000000C4FFFFFF00000B0000000100020000000000000000000300000002000200000000000000
FirstEntry REG_DWORD 0x7d6
LastEntry REG_DWORD 0x7d7
HKLM/SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/Mountain
Standard Time/Dynamic DST
2006 (REG_BINARY) = a4 01 00 00 00 00 00 00
2007 (REG_BINARY) = a4 01 00 00 00 00 00 00
FirstEntry (REG_DWORD) = 0x000007d6 (2006)
LastEntry (REG_DWORD) = 0x000007d7 (2007)
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones\Mountain Standard Time\Dynamic DST
2006 REG_BINARY
A401000000000000C4FFFFFF00000A0000000500020000000000000000000400000001000200000000000000
2007 REG_BINARY
A401000000000000C4FFFFFF00000B0000000100020000000000000000000300000002000200000000000000
FirstEntry REG_DWORD 0x7d6
LastEntry REG_DWORD 0x7d7
# dump of Morocco Dynamic DST
$ reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones\Morocco Standard Time\Dynamic DST" /s
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time
Zones\Morocco Standard Time\Dynamic DST
2007 REG_BINARY
0000000000000000C4FFFFFF0000000000000000000000000000000000000000000000000000000000000000
2008 REG_BINARY
0000000000000000C4FFFFFF000008000000050017003B003B00E703000005000600050017003B003B00E703
2009 REG_BINARY
0000000000000000C4FFFFFF000008000400030017003B003B00E703000005000000050017003B003B00E703
2010 REG_BINARY
0000000000000000C4FFFFFF000008000600010017003B003B00E703000005000600010017003B003B00E703
2011 REG_BINARY
0000000000000000C4FFFFFF000007000600050017003B003B00E703000004000600010017003B003B00E703
2012 REG_BINARY
0000000000000000C4FFFFFF0000090000000500030000000000000000000400000005000200000000000000
2013 REG_BINARY
0000000000000000C4FFFFFF00000A0000000500030000000000000000000400000005000200000000000000
2014 REG_BINARY
0000000000000000C4FFFFFF00000A0000000500030000000000000000000300000005000200000000000000
2015 REG_BINARY
0000000000000000C4FFFFFF00000A0000000500030000000000000000000300000005000200000000000000
2016 REG_BINARY
0000000000000000C4FFFFFF00000A0000000500030000000000000000000300000005000200000000000000
2017 REG_BINARY
0000000000000000C4FFFFFF00000A0000000500030000000000000000000300000005000200000000000000
FirstEntry REG_DWORD 0x7d7
LastEntry REG_DWORD 0x7ed
2020 REG_BINARY
0000000000000000C4FFFFFF0000040000000300030000000000000000000500000005000200000000000000
2021 REG_BINARY
0000000000000000C4FFFFFF0000040000000200030000000000000000000500000003000200000000000000
2022 REG_BINARY
0000000000000000C4FFFFFF0000030000000500030000000000000000000500000002000200000000000000
2023 REG_BINARY
0000000000000000C4FFFFFF0000030000000300030000000000000000000400000004000200000000000000
2024 REG_BINARY
0000000000000000C4FFFFFF0000030000000200030000000000000000000400000002000200000000000000
2025 REG_BINARY
0000000000000000C4FFFFFF0000020000000500030000000000000000000400000001000200000000000000
2026 REG_BINARY
0000000000000000C4FFFFFF0000020000000300030000000000000000000300000004000200000000000000
2027 REG_BINARY
0000000000000000C4FFFFFF0000020000000100030000000000000000000300000002000200000000000000
2028 REG_BINARY
0000000000000000C4FFFFFF0000010000000400030000000000000000000300000001000200000000000000
2029 REG_BINARY
0000000000000000C4FFFFFF0000010000000200030000000000000000000200000003000200000000000000
2018 REG_BINARY
0000000000000000C4FFFFFF00000A0000000400030000000000000000000300000004000200000000000000
2019 REG_BINARY
0000000000000000C4FFFFFF0000010002000100000000000000000000000600000002000200000000000000
]
--
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
- Raw text -