Issue #9 resolved

Regression parsing microseconds

dims
created an issue

Hi,

In version 0.14 when we parsed "1997-08-29T06:14:00.000123Z" we would end up with 123 as the microsecond, now with latest we end up with 123000. Here's the patch to the tests to recreate the problem

thanks, dims

Comments (5)

  1. bnemec

    Edit: Never mind, this fixes the leading zeros case, but breaks others. Will keep looking.

    I believe this can be fixed by changing line 170 of iso8601.py to:

    groups["second_fraction"] = int(Decimal("0.%06d" % to_int(groups, "second_fraction", default_to_zero=True)) * Decimal("1000000.0"))

    The %06d prevents it from dropping the leading zeros.

  2. bnemec

    Okay, another attempt:

    groups["second_fraction"] = int(Decimal("0.%s" % (groups["second_fraction"] or 0)) * Decimal("1000000.0"))

    This time actually verified against the full suite of tests (including dims'). :-)

  3. Log in to comment