Skip to content

Commit

Permalink
removed rounding for sub-second precision in to_datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
hakanakyurek committed Apr 19, 2024
1 parent 12d9cc0 commit 64c0e67
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
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
)

@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

0 comments on commit 64c0e67

Please sign in to comment.