-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: timezone warning for DST beyond 2038-01-18 #33863
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
Changes from all commits
309a822
83846bb
42d827f
16f5c6e
3186296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2265,6 +2265,24 @@ you can use the ``tz_convert`` method. | |
Instead, the datetime needs to be localized using the ``localize`` method | ||
on the ``pytz`` time zone object. | ||
|
||
.. warning:: | ||
|
||
If you are using dates beyond 2038-01-18, due to current deficiencies | ||
in the underlying libraries caused by the year 2038 problem, daylight saving time (DST) adjustments | ||
to timezone aware dates will not be applied. If and when the underlying libraries are fixed, | ||
the DST transitions will be applied. It should be noted though, that time zone data for far future time zones | ||
are likely to be inaccurate, as they are simple extrapolations of the current set of (regularly revised) rules. | ||
|
||
For example, for two dates that are in British Summer Time (and so would normally be GMT+1), both the following asserts evaluate as true: | ||
|
||
.. ipython:: python | ||
|
||
d_2037 = '2037-03-31T010101' | ||
d_2038 = '2038-03-31T010101' | ||
DST = 'Europe/London' | ||
assert pd.Timestamp(d_2037, tz=DST) != pd.Timestamp(d_2037, tz='GMT') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem right to me. If you're going to keep the example (and I'm not convinced you should, especially since it's right around when a DST transition happens - if anything you should move it deep into summer to guarantee that the fluctuations aren't just due to the transition moving around), it would be better to make assertions about the thing you care about. assert pd.Timestamp(d_2037, tz=LON).tzname() != "GMT"
assert pd.Timestamp(d_2038, tz=LON).tzname() != "GMT" Even better, though, would be a repr: >>> pd.Timestamp(d_2037, tz=LON).tzname()
'BST'
>>> pd.Timestamp(d_2037, tz=LON).tzname()
'GMT' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree summer date would be clearer, but not so sure whether your examples are clearer, or whether using BST (local zone name for DST) is clearer for a global audience ... hmmm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't really matter what offsets you use there, pick anything. The important thing is that it's obvious that they are different on the same date in different years, and that it's obvious that that's not due to fluctuations one way or the other in the date of the DST change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it OK to submit further changes once the PR has been approved? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you can submit further changes. I think @pganssle's suggestion about using the repr would be clearer. |
||
assert pd.Timestamp(d_2038, tz=DST) == pd.Timestamp(d_2038, tz='GMT') | ||
|
||
Under the hood, all timestamps are stored in UTC. Values from a time zone aware | ||
:class:`DatetimeIndex` or :class:`Timestamp` will have their fields (day, hour, minute, etc.) | ||
localized to the time zone. However, timestamps with the same UTC value are | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this called
DST
instead ofLON
or some other thing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I am focusing on DST transitions - just happen to have picked London as that's local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People will think it means "this is the Daylight Saving Time zone". You don't have to call it
LON
, but you should at least call itZONE
or something.