fix: datetime offsets

This commit is contained in:
Georg K 2023-11-20 22:46:34 +03:00
parent 1d296f1a88
commit 9ed579fa35

View File

@ -1943,6 +1943,8 @@ class _Timestamp(Timestamp):
# manual epoch offset calulation to avoid rounding errors,
# to support negative timestamps (before 1970) and skirt
# around datetime bugs (apparently 0 isn't a year in [0, 9999]??)
if dt.tzinfo is None:
dt = dt.replace(tzinfo=timezone.utc)
offset = dt - DATETIME_ZERO
# below is the same as timedelta.total_seconds() but without dividing by 1e6
# so we end up with microseconds as integers instead of seconds as float