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

oj_parse_xml_time parses incorrectly unless there are exactly 9 fractional digits #898

Closed
wintonpc opened this issue Aug 30, 2023 · 1 comment · Fixed by #899
Closed

Comments

@wintonpc
Copy link
Contributor

wintonpc commented Aug 30, 2023

Version 3.16.0. The code assumes exactly 9 fractional digits and miscalculates the nanoseconds otherwise. It also adds 500 picoseconds for a reason I don't understand.

Actual behavior

irb> Oj.load('{"^t":"2023-08-30T14:47:45.732-04:00"}', mode: :object).iso8601(12)
"2023-08-30T14:47:45.000000732499-04:00"
irb> Oj.load('{"^t":"2023-08-30T14:47:45.7327237237-04:00"}', mode: :object).iso8601(12)
"2023-08-30T14:47:52.327237237500-04:00"

Expected behavior

irb> Oj.load('{"^t":"2023-08-30T14:47:45.732-04:00"}', mode: :object).iso8601(12)
"2023-08-30T14:47:45.732000000000-04:00"
irb> Oj.load('{"^t":"2023-08-30T14:47:45.7327237237-04:00"}', mode: :object).iso8601(12)
"2023-08-30T14:47:45.732723723700-04:00"

Generally, I would expect the parsed time to == the result of Ruby's Time.parse.

@wintonpc
Copy link
Contributor Author

Looks like the 500 picosecond problem was partially fixed in #810

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

Successfully merging a pull request may close this issue.

1 participant