-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ISO 8601 date parser #1296
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
src/format/parse.rs
Outdated
@@ -224,6 +224,103 @@ pub(crate) fn parse_rfc3339<'a>(parsed: &mut Parsed, mut s: &'a str) -> ParseRes | |||
Ok((s, ())) | |||
} | |||
|
|||
#[derive(Copy, Clone, PartialEq, Eq)] | |||
pub(crate) enum Iso8601Format { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/format/parse.rs
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
NaiveDateTime
andDateTime<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.