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

Keith Thompson Keith.S.Thompson@gmail.com
Tue Jun 8 17:37:37 GMT 2021


There is a known problem with the $TZ environment variable.

Here's a discussion from 2017:
https://cygwin.com/pipermail/cygwin/2017-May/232675.html

The problem is that both Cygwin and Windows use the $TZ environment
variable, but they interpret it differently.

The Windows handling of $TZ (or %TZ%) is documented here:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset?view=msvc-160

For example, Pacific Time is represented as TZ=PST8PDT.

In Cygwin, my $TZ is set by default to "America/Los_Angeles".
Any Windows applications that I invoke from Cygwin, if they attempt
to determine the time zone, will behave inconsistently because they
don't see "America/Los_Angeles" as a valid time zone string.

I've worked around this by unsetting TZ in my .bash_profile .
Cygwin applications are still able to determine the correct time zone.

I suggest that Cygwin should *not* set the TZ environment variable.


More information about the Cygwin mailing list