You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the issues of this repo and believe that this is not a duplicate.
OS version and name: macOS BigSur
Pendulum version: 2.1.2
Issue
pendulum.timezone('+00:00') raises a InvalidTimezone exception
>>> import pendulum
>>> pendulum.timezone("+00:00")
Traceback (most recent call last):
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pendulum/tz/zoneinfo/reader.py", line 50, in read_for
file_path = pytzdata.tz_path(timezone)
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pytzdata/__init__.py", line 74, in tz_path
raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
pytzdata.exceptions.TimezoneNotFound: Timezone +00:00 not found at /Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pytzdata/zoneinfo/+00:00
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pendulum/tz/__init__.py", line 37, in timezone
tz = _Timezone(name, extended=extended)
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pendulum/tz/timezone.py", line 40, in __init__
tz = read(name, extend=extended)
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pendulum/tz/zoneinfo/__init__.py", line 9, in read
return Reader(extend=extend).read_for(name)
File "/Users/rubelagu/tmp/venv-pendulum/lib/python3.8/site-packages/pendulum/tz/zoneinfo/reader.py", line 52, in read_for
raise InvalidTimezone(timezone)
pendulum.tz.zoneinfo.exceptions.InvalidTimezone: Invalid timezone "+00:00"
It's surprising that if you convert a regular datetime.datetime to pendulum it will give you the +00:00 timezone but you can't look up that timezone with pendulum.timezone
one would except that you can serialize a timezone and deserialize safely using the above steps but it will give you a InvalidTimezone for non-named (fixedoffset) timezone. This is something that for example hits Apache Airflow they do keep a timezone attribute and they serialize /deserialize that way and it only works when the timezone you passed was a named timezone.
The text was updated successfully, but these errors were encountered:
In other words, get a regular naive datetime.datetime, converted to iso string , append the +xx:yy and parse with pendulum.parse(). That is a lot of work to get from +00:00 to the corresponding pendulum.tz.timezone.FixedTimezone.
Issue
pendulum.timezone('+00:00')
raises a InvalidTimezone exceptionIt's surprising that if you convert a regular
datetime.datetime
to pendulum it will give you the+00:00
timezone but you can't look up that timezone withpendulum.timezone
one would except that you can serialize a timezone and deserialize safely using the above steps but it will give you a InvalidTimezone for non-named (fixedoffset) timezone. This is something that for example hits Apache Airflow they do keep a timezone attribute and they serialize /deserialize that way and it only works when the timezone you passed was a named timezone.
The text was updated successfully, but these errors were encountered: