localize() fails when offset is too large.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pytz |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I'm playing with custom timezones, some which have an offset that exceeds 24 hours. I am able to convert UTC datetimes into these custom timezones just fine, but using localize() fails.
>>> import datetime
>>> import pytz
>>> dt = pytz.utc.
>>> dt
datetime.
>>> tz = pytz.timezone(
>>> dt.astimezone(tz)
datetime.
>>> dt_local = datetime.
>>> tz.localize(
.../python2.
314 loc_dt = tzinfo.
315 if loc_dt.
--> 316 possible_
317
318 if len(possible_
ValueError: tzinfo.utcoffset() returned 1440; must be in -1439 .. 1439
That is coming from Python's datetime library I'm afraid, and there is nothing pytz can do about it. Its documented in the tzinfo specification.