webrecorder/browsertrix

Fix serialization of datetimes to include Z suffix

tw4l opened this issue · 2 comments

tw4l commented

We store datetimes in UTC but they are not returned with a Z suffix from the API, which requires us to manually add it in the frontend.

We should modify serialization to return timezone from the API. See: https://stackoverflow.com/questions/66548586/how-to-change-date-format-in-pydantic

Ideally we could do this globally so we don't need to modify every class with a datetime.

The PR should also update the frontend where a Z is being added manually.

tw4l commented

Pydantic 2 supports lots of custom serialization: https://docs.pydantic.dev/2.8/concepts/serialization/#custom-serializers. We could likely use the the PlainSerializer to make a custom datetime type that serializes out with the Z suffix.

Since Pydantic 1 doesn't have similarly functionality, this should be considered blocked on upgrading to Pydantic 2. That migration is tracked here: #1940

tw4l commented

Closed with 123705c