fix: _Timestamp.to_datetime works with negative ts

This commit is contained in:
Georg K 2023-04-05 13:02:25 +03:00
parent d2af2f2fac
commit b81195eb44

View File

@ -1578,6 +1578,10 @@ class _Timestamp(Timestamp):
def to_datetime(self) -> datetime:
ts = self.seconds + (self.nanos / 1e9)
if ts < 0:
return datetime(1970, 1, 1) + timedelta(seconds=ts)
else:
return datetime.fromtimestamp(ts, tz=timezone.utc)
@staticmethod