fix: _Timestamp.to_datetime works with negative ts
This commit is contained in:
parent
d2af2f2fac
commit
b81195eb44
@ -1578,7 +1578,11 @@ class _Timestamp(Timestamp):
|
||||
|
||||
def to_datetime(self) -> datetime:
|
||||
ts = self.seconds + (self.nanos / 1e9)
|
||||
return datetime.fromtimestamp(ts, tz=timezone.utc)
|
||||
|
||||
if ts < 0:
|
||||
return datetime(1970, 1, 1) + timedelta(seconds=ts)
|
||||
else:
|
||||
return datetime.fromtimestamp(ts, tz=timezone.utc)
|
||||
|
||||
@staticmethod
|
||||
def timestamp_to_json(dt: datetime) -> str:
|
||||
|
Loading…
x
Reference in New Issue
Block a user