Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Date fields are now properly serialized as ISO dates, i.e. "YYYY-MM-DD" #2580

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion singer_sdk/helpers/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def _conform_primitive_property( # noqa: PLR0911
if isinstance(elem, (datetime.datetime,)):
return to_json_compatible(elem)
if isinstance(elem, datetime.date):
return f"{elem.isoformat()}T00:00:00+00:00"
return elem.isoformat()
if isinstance(elem, datetime.timedelta):
epoch = datetime.datetime.fromtimestamp(0, UTC)
timedelta_from_epoch = epoch + elem
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def test_conform_primitives():
)
assert (
_conform_primitive_property(datetime.date(2020, 5, 17), {"type": "string"})
== "2020-05-17T00:00:00+00:00"
== "2020-05-17"
)
assert (
_conform_primitive_property(datetime.timedelta(365), {"type": "string"})
Expand Down
Loading