chrono
chrono copied to clipboard
Deserialize from string to `DateTime<Utc>`
serde::Deserialize is implemented for DateTime<FixedOffset>, but not for DateTime<Utc>.
This seems like an odd omission. It is inconvenient, because I prefer to use UTC dates exclusively in my application, but I can't use DateTime<Utc> in my structs (at least not without custom serde boilerplate or change of the serialized format from string to number).
Since DateTime<FixedOffset> can be trivially converted to DateTime<Utc>, I'd expect deserializing into DateTime<Utc> work exactly like deserializing into DateTime<FixedOffset> and then converting it to UTC.
On a related note, chrono::serde module has functions for various numeric representations of dates, but not for rfc3339 and other string formats, so I can't use deserialize_with="rfc3339" on DateTime<Utc>.
Seems reasonable to have a Deserialize impl for DateTime<Utc>. Would you be willing to contribute one?
but not for rfc3339 and other string formats, so I can't use deserialize_with="rfc3339" on DateTime<Utc>.
Related to #544