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

Mike Kaganski mikekaganski@mail.ru
Tue Jun 8 13:36:59 GMT 2021


On 08.06.2021 16:04, L A Walsh wrote:
> Look in its environment and remove any thing for timezone and try that.


Thanks to this great suggestion, I was able to workaround this problem - 
thanks!

Wrong result (using the TZ present in environment, i.e. TZ=Europe/Moscow):

> $ "C:/Program 
> Files/WindowsApps/PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0/python3.8.exe"
> Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC 
> v.1928 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import datetime
> >>> datetime.datetime.now()
> datetime.datetime(2021, 6, 8, 14, 31, 19, 163849)

Compared to call with TZ unset:

> $ TZ= "C:/Program 
> Files/WindowsApps/PythonSoftwareFoundation.Python.3.8_3.8.2800.0_x64__qbz5n2kfra8p0/python3.8.exe"
> Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC 
> v.1928 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import datetime
> >>> datetime.datetime.now()
> datetime.datetime(2021, 6, 8, 16, 32, 13, 605201)


Thank you again! This is enough workaround for now. I somehow overlooked 
it, when tried with TZ set to UTC. Shame on me :-)


-- 

Best regards,

Mike Kaganski



More information about the Cygwin mailing list