Python for Windows reports wrong local time when run under Cygwin on Europe/Moscow TZ

Mike Kaganski mikekaganski@mail.ru
Fri Jun 11 06:01:10 GMT 2021


On 08.06.2021 14:37, L A Walsh wrote:
> On 2021/06/06 23:59, Mike Kaganski via Cygwin wrote:
>> Hello,
>>
>> Running Cygwin 3.1.7-1 on Windows 10 Version 21H1 (OS Build 
>> 19043.985), I have this issue:
>>
>> when I start Cygwin's Python, I have correct time reported:
>>
>> But running Python for Windows (it doesn't matter which, specifically 
>> for the test I used the one from MS Store [1]), I have incorrect 
>> local time
>
> ...
>
> Though as to why -- likely the windows version is getting time zone
> clues + correction from BOTH cygwin and Windows, like it's told its
> in a TZ that is at 1 time, while Windows feeds it other data that
> says it is 2 hours off from the default.

As described in Python's issue [1], the problem comes from passing a TZ 
environment variable value that is invalid for Windows C runtime [2]. So 
in the end, it *might* be something for Cygwin to handle.

*If* Cygwin can detect that it starts a native Windows binary (I hope it 
can), then it could try to convert the TZ from Unix kind to Windows 
kind. That way, it could become valid. Or at least it could be unset 
(but that is questionable).

Of course, I could overlook some possible drawbacks from this imagined 
fix, which could make it undesirable. Anyway, I have implemented a 
workaround in our project unsetting TZ before calling Python, and it's 
resolved for us.

Thanks!


[1] https://bugs.python.org/issue44352

[2] 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset?view=msvc-160


-- 

Best regards,

Mike Kaganski



More information about the Cygwin mailing list