Open mre opened 3 months ago
Wow, that's a pretty weird convention. I'm open to this -- I don't think merely starting to accept this would have to be considered a breaking change. Would you be able to submit a PR?
It has been a long documented guarantee of chrono that it doesn't parse 24:00:00, and I suppose there are uses that depend on that. Are you sure this is acceptable?
For the complete ISO 8601 parsers in https://github.com/chronotope/chrono/pull/1143 I added support for this case only when parsing an ISO 8601 formatted datetime.
Description
Would it be possible to support parsing of ISO 8601 datetime strings that use 24:00:00 to represent midnight? Currently, attempting to parse such a string results in an error.
Current Behavior
The following code throws an error:
You can see this behavior in action here: Rust Playground Example
Expected Behavior
The code should successfully parse the datetime string, interpreting 24:00:00 as 00:00:00 of the next day (in this case, 2014-11-29T00:00:00Z).
Rationale
This is a valid ISO 8601 convention, as described in the W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes specification:
W3C XML Schema: Datatypes
Additional Context
It's worth noting that the library already allows a value of 60 for the
second
time component (presumably to account for leap seconds), so there is some precedent for handling edge cases like these.Proposed Solution
Implement a check in the datetime parsing logic that:
Important Considerations
Implementing this change would be a breaking change in the public API. We need to carefully consider potential backwards compatibility issues.