pydantic-core
pydantic-core copied to clipboard
Implement ser_json_temporal config option
Implements the first part of https://github.com/pydantic/pydantic/pull/11504, which is the ser_json_temporal config option.
We now have a ser_json_temporal part to the config, which accepts ['iso8601', 'seconds', 'milliseconds']. These have been implemented as designed in the original pydantic pull request ('iso8601' being obvious, seconds and milliseconds each returning the number of seconds and milliseconds in a float).
This has been done by implementing the serializers for each of the specified types (datetime, date, time, timedelta).
Special case for 'timedelta' where if the old config option is set, it will be used instead of ser_json_temporal.
Related issue number
https://github.com/pydantic/pydantic/pull/11504
Checklist
- [x ] Unit tests for the changes exist
- [x ] Documentation reflects the changes where applicable
- [ ] Pydantic tests pass with this
pydantic-core(except for expected changes) - [ ] My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers
Selected Reviewer: @sydney-runkle