Add ISO 8601 date parser#1296
Conversation
Codecov Report
@@ Coverage Diff @@
## 0.4.x #1296 +/- ##
==========================================
+ Coverage 91.35% 91.41% +0.05%
==========================================
Files 38 39 +1
Lines 17034 17173 +139
==========================================
+ Hits 15562 15698 +136
- Misses 1472 1475 +3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Maybe we should move all the ISO 8601 parsing code into a module of its own? Edit: moved to a new module. |
2c2e1b1 to
9f21d60
Compare
| } | ||
|
|
||
| #[derive(Copy, Clone, PartialEq, Eq)] | ||
| pub(crate) enum Iso8601Format { |
There was a problem hiding this comment.
This enum serves no purpose yet. We need it to make sure that the date, time and offset components use the same format when parsing to a NaiveDateTime, DateTime or duration.
| pub(crate) fn parse_iso8601_date<'a>( | ||
| parsed: &mut Parsed, | ||
| mut s: &'a str, | ||
| ) -> ParseResult<(&'a str, Iso8601Format)> { |
There was a problem hiding this comment.
To reuse this method for parsing a duration it should take a flag to indicate it should not parse week date formats.
9f21d60 to
37ba280
Compare
As far as motivations go, I find these to be fairly weak, so I don't think I'm going to prioritize reviewing these for the near future. |
@djc #1143 seems a bit too large to review. But the first few commits make sense on their own.
This is the commit that adds an ISO 8601 date parser.
The parser would be used by
NaiveDate::parse_from_iso8601().It is a component for the ISO 8601 parsers for
NaiveDateTimeandDateTime<FixedOffset>.But ISO 8601 also specifies that the date components of a duration can use the date formats supported by this parser, with the exception of the formats for a week date.