-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt: add APIs for skipping weekday checking
In the course of doing some experiments with using Jiff in `gix-date`, I discovered that it currently relies on the fact that parsing RFC 2822 datetimes (and similar) does *not* do error checking if the date and weekday are inconsistent. Prior to this PR, Jiff required that the weekday and date were consistent. This PR adds APIs for skipping this check. For RFC 2822, this adds a new `relaxed_weekday` configuration on the `DateTimeParser` builder. For the strtime APIs, we achieve this by adding more granular accessors and mutators on `BrokenDownTime`. So now folks can do this: ``` let tm = BrokenDownTime::parse("%a, %F", "Wed, 2024-07-27")?; tm.set_weekday(None); assert_eq!(tm.to_date().unwrap(), jiff::civil::date(2024, 7, 27)); ``` Where the above succeeds even though 2024-07-27 was a Saturday. It's a little verbose, but my hope is that this is a rarely needed thing.
- Loading branch information
1 parent
a995d01
commit 70c6ca0
Showing
3 changed files
with
631 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.