regebro / tzlocal

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

Add missing string formatter to ZoneInfoNotFoundError #129

Closed CalebJohn closed 2 years ago

CalebJohn commented 2 years ago

Previously there was a string interpolation sign (%s) but nothing was being added. This change adds tzenv to give a better error message.

Before

>>> import tzlocal
>>> tzlocal.utils._tz_from_env("US/Chicago")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/caleb/Downloads/tzlocal/tzlocal/utils.py", line 125, in _tz_from_env
    raise ZoneInfoNotFoundError(
tzlocal.utils.ZoneInfoNotFoundError: 'tzlocal() does not support non-zoneinfo timezones like %s. \nPlease use a timezone in the form of Continent/City'

After

>>> import tzlocal
>>> tzlocal.utils._tz_from_env("US/Chicago")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/caleb/Downloads/tzlocal/tzlocal/utils.py", line 125, in _tz_from_env
    raise ZoneInfoNotFoundError(
tzlocal.utils.ZoneInfoNotFoundError: 'tzlocal() does not support non-zoneinfo timezones like US/Chicago. \nPlease use a timezone in the form of Continent/City'
regebro commented 2 years ago

Thanks!