regebro / tzlocal

A Python module that tries to figure out what your local timezone is
MIT License
185 stars 58 forks source link

get_localzone does not respect default GNU libc value for $TZ #125

Closed robnagler closed 2 years ago

robnagler commented 2 years ago

21.5.6 Specifying the Time Zone with TZ:

If the TZ environment variable does not have a value, the operation chooses a time zone by default. In the GNU C Library, the default time zone is like the specification ‘TZ=:/etc/localtime’ (or ‘TZ=:/usr/local/etc/localtime’, depending on how the GNU C Library was configured; see Installation).

$ TZ=:/etc/localtime python -c 'import tzlocal; print(tzlocal.get_localzone())'
local

Why set $TZ at all? There's a serious performance issue on Red Hat when TZ is not set.

regebro commented 2 years ago

I'll check it out. This format should be supported, but I do see I forgot to strip away the leading ":" in the _tz_name_from_env() function, maybe this confuses things.

regebro commented 2 years ago

4.2 should solve this