Seconds in str(DateTime()) are not zero-padded

Bug #267800 reported by Artur Zaprzała
2
Affects Status Importance Assigned to Milestone
DateTime
Invalid
Medium
Unassigned

Bug Description

__str__() method of DateTime is using '%06.6f' format for seconds, which clearly is not what the author intended. It should be '%09.6f'.
A bad thing is that everyone is using diffrent format string for the same result. For example, the following formats are equivalent: '%02d', '%02.2d', '%2.2d', '%.2d'.

By the way I found a bug in _tzoffset2rfc822zone() and _tzoffset2iso8601zone(). Someone overlooked that in Python division is a floor division. As a result, a timezone '-0230' will be formatted as '-0330'.

The attached patch will do the following:
 - fix __str__ method,
 - make all format strings consistent,
 - fix _tzoffset2rfc822zone() and _tzoffset2iso8601zone() functions,
 - change _findLocalTimeZoneName() to use _tzoffset2rfc822zone() instead of a very complicated code.

Revision history for this message
Artur Zaprzała (arturz) wrote :
Revision history for this message
Tres Seaver (tseaver) wrote :

This patch looks reasonable. Needs tests.

affects: zope2 → datetime
Changed in datetime:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Colin Watson (cjwatson) wrote :

The datetime project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/datetime.

Changed in datetime:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.