[egenix-users] DateTime formatting issue

Vovan Sim vovansim at gmail.com
Mon Jan 9 11:01:27 CET 2012


Hello,

There seems to be an issue with DateTime formatting in mxBase 3.2.

Imagine the following scenario: I have a datetime object that I turn
into a float using absdays, and then create a new date time object
from the float using DateTimeFromAbsDays. In the previous version I
was using (mxBase 3.0) this behaved correctly:



>>> from mx import DateTime

>>> DateTime.__version__
'3.0.0'

>>> print DateTime.DateTimeFromAbsDays(DateTime.DateTimeFrom('2009-01-03 01:31:00.00').absdays)
2009-01-03 01:30:59.99



You can see that the new object is off by one hundredth of a second.
This is OK, it's obviously an inevitable consequence of this
transformation caused by float rounding errors.

However, in the new version, the output is a little different:



>>> from mx import DateTime

>>> DateTime.__version__
'3.2.1'

>>> print DateTime.DateTimeFromAbsDays(DateTime.DateTimeFrom('2009-01-03 01:31:00.00').absdays)
2009-01-03 01:30:60.00



You can see that the output is rounded to 60 seconds, instead of
59.99. This is a bit of an issue, because now it's an illegally
formatted date, and in fact if I try to parse this string, I get an
error:



>>> print DateTime.DateTimeFrom('2009-01-03 01:30:60.00')
Traceback (most recent call last)
[... snip ...]
RangeError: Failed to parse "2009-01-03 01:30:60.00": second out of
range (0.0 - <60.0; <61.0 for 23:59): 60



Since it breaks the parsing, it seems to me that the output of 59.99
seconds would be preferable to 60.00 seconds. Is that something that
you guys think you could look into?

Thanks,
V



More information about the egenix-users mailing list