Skip to content

Commit

Permalink
Fix date default which should be number of days since 1970-1-1
Browse files Browse the repository at this point in the history
Previous logic was dependant on timezone
  • Loading branch information
faph committed Nov 6, 2023
1 parent ac2521b commit f676c12
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/py_avro_schema/_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def data(self, names: NamesType) -> JSONObj:

def make_default(self, py_default: datetime.date) -> int:
"""Return an Avro schema compliant default value for a given Python value"""
return (py_default - datetime.date.fromtimestamp(0)).days
return (py_default - datetime.date(1970, 1, 1)).days


class TimeSchema(Schema):
Expand Down

0 comments on commit f676c12

Please sign in to comment.