DateTimeFromString off by one sec?

Hi,

I am using mx.DateTime to parse dates and times in ISO format. I have
noticed that DateTimeFromString seems to be off by one second if the
time string being parsed ends with :59

>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.59')
<mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 651a8>

but

>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.58')
<mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 8c250>

Adding formats=['iso', ] does not change the results. I am using
mx.DateTime 3.0 by the way.

Am I doing something wrong?

Thank you!
Francesco

_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users

M.-A. Lemburg | 7 May 10:33
Favicon

Re: DateTimeFromString off by one sec?

On 2008-05-06 23:27, Francesco Pierfederici wrote:
> Hi,
> 
> I am using mx.DateTime to parse dates and times in ISO format. I have
> noticed that DateTimeFromString seems to be off by one second if the
> time string being parsed ends with :59
> 
>>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.59')
> <mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 651a8>
> 
> but
> 
>>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.58')
> <mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 8c250>
> 
> Adding formats=['iso', ] does not change the results. I am using
> mx.DateTime 3.0 by the way.
> 
> 
> Am I doing something wrong?

It is not not off by a second, it's off by 1/100 of a second.

This looks a lot like a bug in the parser, since it starts to
parse the fraction with a 1/100 second offset starting at
x.59 onwards:

 >>> DateTimeFrom('2008-05-06 19:30:09.57')
<mx.DateTime.DateTime object for '2008-05-06 19:30:09.57' at 2b1e3bdb08c8>

(Continue reading)

M.-A. Lemburg | 7 May 11:00
Favicon

Re: DateTimeFromString off by one sec?

On 2008-05-07 10:33, M.-A. Lemburg wrote:
> On 2008-05-06 23:27, Francesco Pierfederici wrote:
>> Hi,
>>
>> I am using mx.DateTime to parse dates and times in ISO format. I have
>> noticed that DateTimeFromString seems to be off by one second if the
>> time string being parsed ends with :59
>>
>>>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.59')
>> <mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 651a8>
>>
>> but
>>
>>>>> mx.DateTime.Parser.DateTimeFromString('2008-05-06T19:30:09.58')
>> <mx.DateTime.DateTime object for '2008-05-06 19:30:09.58' at 8c250>
>>
>> Adding formats=['iso', ] does not change the results. I am using
>> mx.DateTime 3.0 by the way.
>>
>>
>> Am I doing something wrong?
> 
> It is not not off by a second, it's off by 1/100 of a second.
> 
> This looks a lot like a bug in the parser, since it starts to
> parse the fraction with a 1/100 second offset starting at
> x.59 onwards:
> 
>  >>> DateTimeFrom('2008-05-06 19:30:09.57')
> <mx.DateTime.DateTime object for '2008-05-06 19:30:09.57' at 2b1e3bdb08c8>
(Continue reading)


Gmane