◐ Shell
reader mode source ↗
Skip to content

Avoid using floating points during timestamp-datetime conversions#591

Merged
methane merged 4 commits into
msgpack:mainfrom
hakanakyurek:precise-datetime-conversion
Apr 19, 2024
Merged

Avoid using floating points during timestamp-datetime conversions#591
methane merged 4 commits into
msgpack:mainfrom
hakanakyurek:precise-datetime-conversion

Conversation

@hakanakyurek

Copy link
Copy Markdown
Contributor

Right now, when we convert timestamp to datetime or datetime to timestamp, the library uses floating points to do the conversion. This introduces losses during the conversion as the datetime and timestamp datatypes do not support the same precision(nanoseconds).

For instance if we have a timestamp such as:
2024-04-16 08:43:09.420317+00:00
with the current implementation the nanoseconds in the resulting Timestamp object has 420316934 while it should be 420317000 instead.

or in this timestamp:
2024-04-16 08:43:09.400000+00:00
it has 400000095 nanoseconds instead of 400000000.

@hakanakyurek hakanakyurek changed the title Avoid using floaring points during timestamp-datetime conversions Apr 18, 2024

@ThomasWaldmann ThomasWaldmann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

LGTM, just a few nitpicks.

I assume that these tests fail without your changes?

@hakanakyurek

Copy link
Copy Markdown
Contributor Author

Exactly, the tests i added except line 100 should fail without the changes.

@methane methane merged commit e776722 into msgpack:main Apr 19, 2024
@methane

methane commented Apr 19, 2024

Copy link
Copy Markdown
Member

thanks

@uyha uyha mentioned this pull request Apr 24, 2024
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 this pull request may close these issues.

3 participants