diff --git a/src/betterproto/__init__.py b/src/betterproto/__init__.py index b2a63d8..1b072c2 100644 --- a/src/betterproto/__init__.py +++ b/src/betterproto/__init__.py @@ -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