Open abhikeny opened 1 month ago
More REPL traces:
dateutil.parser.parse
returns same data:
>>> parse("2036-05-02 07:00:00.000000 +00:00")
datetime.datetime(2036, 5, 2, 7, 0, tzinfo=tzutc())
>>> parse("2037-05-02 07:00:00.000000 +00:00")
datetime.datetime(2037, 5, 2, 7, 0, tzinfo=tzutc())
>>> parse("2038-05-02 07:00:00.000000 +00:00")
datetime.datetime(2038, 5, 2, 7, 0, tzinfo=tzutc())
tz_obj
causes discrepancy from 2038:
>>> from pytz import timezone
>>> tz_obj = timezone("US/Pacific")
>>> parse("2036-05-02 07:00:00.000000 +00:00").astimezone(tz_obj)
datetime.datetime(2036, 5, 2, 0, 0, tzinfo=<DstTzInfo 'US/Pacific' PDT-1 day, 17:00:00 DST>)
>>> parse("2037-05-02 07:00:00.000000 +00:00").astimezone(tz_obj)
datetime.datetime(2037, 5, 2, 0, 0, tzinfo=<DstTzInfo 'US/Pacific' PDT-1 day, 17:00:00 DST>)
>>> parse("2038-05-02 07:00:00.000000 +00:00").astimezone(tz_obj)
datetime.datetime(2038, 5, 1, 23, 0, tzinfo=<DstTzInfo 'US/Pacific' PST-1 day, 16:00:00 STD>)
pytz does not support dates after 2038-01-19 03:14:07 UTC, as far as I know. See https://en.wikipedia.org/wiki/Year_2038_problem
Oh! That's interesting, @bxparks . Thanks for sharing this detail.
If Python's built-in zoneinfo
module does not have that issue, is there any reason that pytz can't be updated to handle the y2038 problem?
Aside from changing to the 64-bit version of TZDB, tracking down every reference to the 32-bit epochseconds, updating all the tests, and verifying that everything is 100% backwards compatible and works correctly, I suppose no reason at all, except for time and motivation from the pytz maintainer (a single person I believe).
The Y2038 problem for pytz is a long-standing issue, see #31 for example. You should consider migrating to zoneinfo if this problem is important for you.
Why is the same date (May 2nd) in 2 different years (2019 vs. 2098) being converted to PDT in 2019 but PST in 2098?
Seems like some strange behavior in this package's
timezone().localize()
function, since the output of dateutil'sparser.parse()
does not really change except for the year which is passed in.Environment:
Thanks in advance for looking into this.