chrono icon indicating copy to clipboard operation
chrono copied to clipboard

`NaiveDateTime` fails to deserialize ISO 8601

Open ok-nick opened this issue 4 years ago • 0 comments

I'm trying to deserialize an ISO 8601 date which includes a trailing Z. Weirdly enough, the deserializer doesn't seem to support this and going further into the code, it seems the implementation is very unusual? https://github.com/chronotope/chrono/blob/3467172c31188006147585f6ed3727629d642fed/src/naive/datetime.rs#L1483 In this trait implementation (which is called by the deserializer internally), a hardcoded customized format is used, which is very unusual when it should default to the ISO 8601 format. I'm not sure if this trait is implemented for testing, debugging, or other reasons, but it would make more sense if the deserializer called parse_from_str (or the parsing function directly) internally with a default format of %+.

Here is an example of my current situation highlighting the differences between parse_from_str with a format of %+ and the deserializer; https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=836fac98df345c97cf9241b89c273fa5

ok-nick avatar Aug 08 '21 03:08 ok-nick