Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removed rounding for sub-second precision in to_datetime
  • Loading branch information
hakanakyurek committed Apr 19, 2024
commit 64c0e6797ffbe29c8c533cdf58a17d9ea64e1ad6
2 changes: 1 addition & 1 deletion msgpack/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def to_datetime(self):
"""
utc = datetime.timezone.utc
return datetime.datetime.fromtimestamp(0, utc) + datetime.timedelta(
seconds=self.seconds, microseconds=round(self.nanoseconds / 1e3)
seconds=self.seconds, microseconds=self.nanoseconds // 1e3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
seconds=self.seconds, microseconds=self.nanoseconds // 1e3
seconds=self.seconds, microseconds=self.nanoseconds // 1000

)

@staticmethod
Expand Down
5 changes: 0 additions & 5 deletions test/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ def test_timestamp_datetime():

assert Timestamp.from_datetime(ts).to_datetime() == ts

t2 = Timestamp(1713256989, 420318123)
t3 = Timestamp(1713256989, 420318499)
t4 = Timestamp(1713256989, 420318501)
assert t2.to_datetime() == t3.to_datetime() != t4.to_datetime()


def test_unpack_datetime():
t = Timestamp(42, 14)
Expand Down