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

Wrong DST for dates after year 2038 #31

Open
amiart opened this issue Aug 20, 2019 · 5 comments
Open

Wrong DST for dates after year 2038 #31

amiart opened this issue Aug 20, 2019 · 5 comments

Comments

@amiart
Copy link

amiart commented Aug 20, 2019

When I create UTC date after 2038 year and then change the timezone to eg. 'Europe/Warsaw' the DST is wrong.

For example, in june Warsaw is in GMT+2 time zone so when I set UTC time to 10:00 the time in Warsaw should be 12:00.

Code to reproduce bug:

Date before 2038, gives 12:00. everything OK:

>>> utc_dt = datetime(2037, 6, 1, 10, 0, 0, tzinfo=pytz.utc)
>>> utc_dt
datetime.datetime(2037, 6, 1, 10, 0, tzinfo=<UTC>)
>>> loc_dt = utc_dt.astimezone(timezone('Europe/Warsaw'))
>>> loc_dt
datetime.datetime(2037, 6, 1, 12, 0, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)

Date after 2038, should be 12:00, but gives 11:00:

>>> utc_dt = datetime(2038, 6, 1, 10, 0, 0, tzinfo=pytz.utc)
>>> utc_dt
datetime.datetime(2038, 6, 1, 10, 0, tzinfo=<UTC>)
>>> loc_dt = utc_dt.astimezone(timezone('Europe/Warsaw'))
>>> loc_dt
datetime.datetime(2038, 6, 1, 11, 0, tzinfo=<DstTzInfo 'Europe/Warsaw' CET+1:00:00 STD>)

@stub42
Copy link
Owner

stub42 commented Aug 20, 2019

pytz only understands the 'old' IANA timezone database binary format and has a Y2038 bug. Work on fixing this should probably go into Python core, adding a tzfile implementation that supports the modern format.

@kurt-rhee
Copy link

I also have this issue.

@pganssle
Copy link

Work on fixing this should probably go into Python core, adding a tzfile implementation that supports the modern format.

For anyone finding this thread later: this has been done. The zoneinfo module was added in Python 3.9 and there is a backport available to Python 3.6.

@septatrix
Copy link

Any recent progress towards supporting the newer format or working with the zoneinfo module?

@ClementJeannesson
Copy link

ClementJeannesson commented Mar 15, 2022

Same issue here.

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

6 participants