Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing date with over 999999 in microseconds #636

Closed
matthewdooler opened this issue Aug 15, 2019 · 3 comments · Fixed by #643
Closed

Error parsing date with over 999999 in microseconds #636

matthewdooler opened this issue Aug 15, 2019 · 3 comments · Fixed by #643

Comments

@matthewdooler
Copy link
Contributor

matthewdooler commented Aug 15, 2019

I get the following error if I try to parse a date with a timestamp that has over 6 digits in the fractional second and is also over 999999:

microsecond must be in 0..999999

Example inputs: 2019-08-14T15:37:11.9999995+01:00, 2019-08-14T15:37:11.9999996+01:00 but not 2019-08-14T15:37:11.9999994+01:00

Arrow version: 0.14.5
Python version: 3.7.3

Seems related to #341 but not quite the same issue.

@matthewdooler
Copy link
Contributor Author

This is my current workaround as I don't need the precision - I just need to be able to accept the date and do a rough calculation:

s = "2019-08-14T15:37:11.9999995+01:00"
bad_millis = [".9999995", ".9999996", ".9999997", ".9999998", ".9999999"]
for bad_milli in bad_millis:
    s = s.replace(bad_milli, ".9999994")
t = arrow.get(s)

@jadchaar jadchaar added the bug label Aug 16, 2019
@jadchaar
Copy link
Member

Hey @matthewdooler, thanks for the bug report. This is due to the rounding logic here: https://github.com/crsmithdev/arrow/blob/master/arrow/parser.py#L232.

We need to add a conditional to account for the case in which it overflows from 999999 to 1000000 to zero out the subseconds and increment the seconds.

If you'd like to take a whack at this issue, feel free to submit a PR. Any help is appreciated :).

@matthewdooler
Copy link
Contributor Author

Have raised a PR if anyone could take a look :)

#643

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants