Skip to content

Commit

Permalink
Parse int to to date via a timezone-aware UTC datetime rather than di…
Browse files Browse the repository at this point in the history
…rectly using date.fromtimestamp(), as the latter returns a date in the local timezone
  • Loading branch information
msinto93 committed Mar 8, 2024
1 parent 11e4550 commit d8e0210
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/py_adapter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def _parse_date(self, data: Union[datetime.date, int, str], schema: avro.schema.
if isinstance(data, int):
# Assume we have serialized as a timestamp in milliseconds. Now that is NOT how we would have serialized it
# if it was Avro. So this is useful only in combination with serializing using ``datetime_type=int``.
return datetime.date.fromtimestamp(data / 1e3)
return datetime.datetime.fromtimestamp(data / 1e3, tz=datetime.timezone.utc).date()
elif isinstance(data, str):
return dateutil.parser.isoparse(data).date()
else:
Expand Down

0 comments on commit d8e0210

Please sign in to comment.