[issue5288] tzinfo objects with sub-minute offsets are not supported (e.g. UTC+05:53:28)

Tim Peters report at bugs.python.org
Wed Aug 12 19:59:30 CEST 2015


Tim Peters added the comment:

> The only reason for the restriction that
> I can think of is that some text representation
> of datetime only provide 4 digits for timezone.

There never was a compelling reason.  It was simply intended to help catch programming errors for a (at the time) brand new feature, and one where no concrete timezone support was supplied at first.  Lots of people were writing their own tzinfo subclasses, and nobody at the time was, e.g., volunteering to wrap the Olson database.

I'm in favor of removing all restrictions on offsets.  Speed is of minor concern here - if it simplifies the code to delegate all offset arithmetic to classic datetime +/- timedelta operations, fine.

String representations are a mess.  If some popular standard doesn't cater to sub-minute (or sub-second!) offsets, fine, make up a format consistent with what such a standard "would have" defined had it addressed the issue, and document that if a programmer picks a timezone whose offsets go beyond what that standard supports, tough luck.  Then Python will give something sensible Python can live with, but won't try to hide that what they're doing does in fact go beyond what the standard supports.

----------
nosy: +tim.peters

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5288>
_______________________________________


More information about the Python-bugs-list mailing list