You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow timezone offsets greater than 24 hours #69167
This seems like an arbitrary restriction, and prevents the library from being used in arbitrary timezone translations. For various reasons, one might need to start a new day (perhaps to implement some business logic) during the regular day. Depending on when/where this is, the effective offset can easily be greater than 24 hours.
ValueError: tzinfo.utcoffset() returned 1440; must be in -1439 .. 1439
Note that although only offsets within 24 hours are supported, it seems to be possible to use astimezone() with arbitrary offsets. So perhaps we gain consistency in removing the restriction altogether?
This would not be unprecedented. RFC 2822 allows any offset
representable as HHMM: "the zone MUST be within the range -9959
through +9959" Section 3.3 of http://tools.ietf.org/html/rfc2822.html
The timezone offset range restriction is not arbitrary. It was discussed in bpo-5094 (see msg107059 and responses to it.)
Nevertheless, there is an open proposal to remove all restrictions on offset values and allow it to be an arbitrary timedelta. See bpo-5288, msg248468.
I think we should consolidate this issue with bpo-5288.
BTW, the specific issue that OP complains about is not a datetime issue: apparently pytz has an even tighter restriction on timezone offsets.
I am going to close this as a third party issues, but those who support relaxing datetime.timezone restriction to ±24h range are invited to participate in bpo-5288 discussion.
Thanks for the pointer to bpo-5288. Happy to consolidate there.
In my reading of bpo-5094 (from which I pulled your RFC 2822 reference), the justification I found was "For the allowable range, follow the datetime docs as someone might be relying on that specification already". But this didn't explain why it was in the spec in the first place, and that is the decision I thought was arbitrary, not the decision to maintain the restriction. Splitting hairs at this point. Looking forward to the restriction being removed.
Activity
tjhnson commentedon Sep 1, 2015
The datetime module only supports timezone offsets within 24 hours of UTC:
https://docs.python.org/3/library/datetime.html#datetime.tzinfo.utcoffset
This seems like an arbitrary restriction, and prevents the library from being used in arbitrary timezone translations. For various reasons, one might need to start a new day (perhaps to implement some business logic) during the regular day. Depending on when/where this is, the effective offset can easily be greater than 24 hours.
ValueError: tzinfo.utcoffset() returned 1440; must be in -1439 .. 1439
Note that although only offsets within 24 hours are supported, it seems to be possible to use astimezone() with arbitrary offsets. So perhaps we gain consistency in removing the restriction altogether?
This would not be unprecedented. RFC 2822 allows any offset
representable as HHMM: "the zone MUST be within the range -9959
through +9959" Section 3.3 of http://tools.ietf.org/html/rfc2822.html
abalkin commentedon Sep 2, 2015
The timezone offset range restriction is not arbitrary. It was discussed in bpo-5094 (see msg107059 and responses to it.)
Nevertheless, there is an open proposal to remove all restrictions on offset values and allow it to be an arbitrary timedelta. See bpo-5288, msg248468.
I think we should consolidate this issue with bpo-5288.
abalkin commentedon Sep 2, 2015
BTW, the specific issue that OP complains about is not a datetime issue: apparently pytz has an even tighter restriction on timezone offsets.
I am going to close this as a third party issues, but those who support relaxing datetime.timezone restriction to ±24h range are invited to participate in bpo-5288 discussion.
tjhnson commentedon Sep 3, 2015
Thanks for the pointer to bpo-5288. Happy to consolidate there.
In my reading of bpo-5094 (from which I pulled your RFC 2822 reference), the justification I found was "For the allowable range, follow the datetime docs as someone might be relying on that specification already". But this didn't explain why it was in the spec in the first place, and that is the decision I thought was arbitrary, not the decision to maintain the restriction. Splitting hairs at this point. Looking forward to the restriction being removed.
abalkin commentedon Sep 3, 2015
I always thought that restriction came from ISO 8601, but at the moment I don't have it to check.