regebro / tzlocal

A Python module that tries to figure out what your local timezone is

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unsupported timezone from tzenv

celestianx opened this issue · comments

Hi,

I have been executing some python code on a Synology x86 architecture and:

tzlocal.get_localzone())

returns:

CET-1CEST,M3.5.0,M10.5.0/3

which is not recognized as a supported timezone by pytz when pytz.timezone() is called.

While I don't know why it returns this, if I take a look at /etc/sysconfig/clock, timezone information are proper.

So basically, instead of:

 if tzenv:
       return _tz_from_env(tzenv)

There should be an exception handler in case this approach doesn't work to let the code proceed and try to look in the system files.

Like

if tzenv:
        try:
            return _tz_from_env(tzenv)
        except pytz.UnknownTimeZoneError, e:
            pass

Or whatever exception should make sense