Skip to content

Python datetime serialisation/deserialisation not working correctly without timezone #71

@cimpeanvasile

Description

@cimpeanvasile

There seems to be an issue with serialising and deserialising datetimes for python generated dataclasses.
This example fails with ValueError: ('Invalid RFC3339 date/time', '2023-01-01T00:00:00'):

some_dataclass = SomeDataclass(some_time=datetime(2023, 1, 1, 0, 0, 0))
json_data = some_dataclass.to_json_data()
some_dataclass = SomeDataclass.from_json_data(json_data)

It seems to be because the serialising to json for datetime is just datetime.isoformat(), which will return '2023-01-01T00:00:00' for the mentioned value. This will then fail the check in the generated dataclass' _parse_rfc3339 function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions