Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create timezone from shortcode #750

Open
2 tasks done
hussein-awala opened this issue Sep 19, 2023 · 2 comments
Open
2 tasks done

Unable to create timezone from shortcode #750

hussein-awala opened this issue Sep 19, 2023 · 2 comments

Comments

@hussein-awala
Copy link

  • I am on the latest Pendulum version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS version and name: Ubuntu 20.04.1
  • Pendulum version: 2.1.2

Issue

It looks like we cannot recreate a Timezone instance from all the timezones shortcodes:

>>> pendulum.timezone("Europe/Paris").tzname(dt)
'CET'
>>> pendulum.timezone("CET")
Timezone('CET')
>>> pendulum.timezone("America/New_York").tzname(dt)
'EDT'
>>> pendulum.timezone("EDT")
Traceback (most recent call last):
  File "/-env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/reader.py", line 50, in read_for
    file_path = pytzdata.tz_path(timezone)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/pytzdata/__init__.py", line 74, in tz_path
    raise TimezoneNotFound('Timezone {} not found at {}'.format(name, filepath))
pytzdata.exceptions.TimezoneNotFound: Timezone EDT not found at /env/lib/python3.11/site-packages/pytzdata/zoneinfo/EDT

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/env/lib/python3.11/site-packages/pendulum/tz/__init__.py", line 37, in timezone
    tz = _Timezone(name, extended=extended)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/-env/lib/python3.11/site-packages/pendulum/tz/timezone.py", line 40, in __init__
    tz = read(name, extend=extended)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/__init__.py", line 9, in read
    return Reader(extend=extend).read_for(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/env/lib/python3.11/site-packages/pendulum/tz/zoneinfo/reader.py", line 52, in read_for
    raise InvalidTimezone(timezone)
pendulum.tz.zoneinfo.exceptions.InvalidTimezone: Invalid timezone "EDT"

related: apache/airflow#34483

@issamansur
Copy link

issamansur commented Sep 19, 2023

@hussein-awala, hi. Try use Eastern Standard Time (EST):
pendulum.timezone("EST")
instead of
pendulum.timezone("EDT")

@issamansur
Copy link

issamansur commented Sep 19, 2023

Also check this post, there are reasons why EDT and other can not in timezones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants