From 34ab27319836654a369d54dac71ec6302fc5b73d Mon Sep 17 00:00:00 2001 From: hakan Date: Fri, 19 Apr 2024 17:42:18 +0200 Subject: [PATCH] 1e3/10**3 --> 1000 --- msgpack/ext.py | 4 ++-- test/test_timestamp.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/msgpack/ext.py b/msgpack/ext.py index 7fdad86f..3940fe0f 100644 --- a/msgpack/ext.py +++ b/msgpack/ext.py @@ -158,7 +158,7 @@ def to_datetime(self): """ utc = datetime.timezone.utc return datetime.datetime.fromtimestamp(0, utc) + datetime.timedelta( - seconds=self.seconds, microseconds=self.nanoseconds // 1e3 + seconds=self.seconds, microseconds=self.nanoseconds // 1000 ) @staticmethod @@ -167,4 +167,4 @@ def from_datetime(dt): :rtype: Timestamp """ - return Timestamp(seconds=int(dt.timestamp()), nanoseconds=dt.microsecond * 10**3) + return Timestamp(seconds=int(dt.timestamp()), nanoseconds=dt.microsecond * 1000) diff --git a/test/test_timestamp.py b/test/test_timestamp.py index ce786edb..f9bc8353 100644 --- a/test/test_timestamp.py +++ b/test/test_timestamp.py @@ -89,12 +89,14 @@ def test_timestamp_datetime(): ts = datetime.datetime(2024, 4, 16, 8, 43, 9, 420317, tzinfo=utc) ts2 = datetime.datetime(2024, 4, 16, 8, 43, 9, 420318, tzinfo=utc) - assert Timestamp.from_datetime(ts2).nanoseconds - Timestamp.from_datetime(ts).nanoseconds == 1e3 + assert ( + Timestamp.from_datetime(ts2).nanoseconds - Timestamp.from_datetime(ts).nanoseconds == 1000 + ) ts3 = datetime.datetime(2024, 4, 16, 8, 43, 9, 4256) ts4 = datetime.datetime(2024, 4, 16, 8, 43, 9, 4257) assert ( - Timestamp.from_datetime(ts4).nanoseconds - Timestamp.from_datetime(ts3).nanoseconds == 1e3 + Timestamp.from_datetime(ts4).nanoseconds - Timestamp.from_datetime(ts3).nanoseconds == 1000 ) assert Timestamp.from_datetime(ts).to_datetime() == ts