[issue5094] datetime lacks concrete tzinfo impl. for UTC
report at bugs.python.org
Thu Jun 3 20:46:34 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
I am attaching the next installment of the datetime.timezone class implementation.
Here I add ``utc`` class attribute to timezone. I decided to place it in class rather than module namespace because this seems to be more inline with how datetime module defines particular instances of its classes such as ``min``, ``max`` and ``resolution``. I also feel that writing ``timezone.utc`` makes it clearer that its is an instance of ``timezone`` class while ``datetime.UTC`` or simply ``UTC`` is more ambiguous.
I also changed ``timezone`` constructor to interpret int or float offset as number of hours and accept arbitrary timedelta between timedelta(hours=-12) and timedelta(hours=12). The rationale is that most common timezones have offsets at whole hours and less common but existing timezones use 1/2 or 1/4 hour offsets and thus can be specified as a binary float without any issue.
I've added tests and some preliminary documentation.
Added file: http://bugs.python.org/file17533/issue5094a.diff
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list