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

Bug #267800 reported by Artur Zaprzała on 2008-09-08
Affects Status Importance Assigned to Milestone

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.

Artur Zaprzała (arturz) wrote :
Tres Seaver (tseaver) wrote :

This patch looks reasonable. Needs tests.

affects: zope2 → datetime
Changed in datetime:
importance: Undecided → Medium
status: New → Triaged
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers