1. Michael Twomey
  2. pyiso8601
  3. Issues
Issue #2 resolved

Roundoff issues when parsing decimal seconds

Michael Twomey
repo owner created an issue

Original: https://code.google.com/p/pyiso8601/issues/detail?id=21

Reported by nielsenb@jetfuse.net, Dec 19, 2012 What steps will reproduce the problem?

from iso8601 import parse_date parse_date('2012-12-19T23:21:28.512400+00:00') datetime.datetime(2012, 12, 19, 23, 21, 28, 512399, tzinfo=<FixedOffset '+00:00'>)

What is the expected output? What do you see instead?

I would expect 512400 as the microsecond value, instead 512399 appears.

What version of the product are you using? On what operating system?

0.1.4

Fedora 17, 64 bit.

Please provide any additional information below.

I have attached a patch which contains both a unit test for the situation presented above, and a fix using a Decimal object instead of a cast to float. This fix would break compatibility with Python versions earlier than 2.5.

Comments (1)

  1. Log in to comment