Skip to content
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

fmt: add APIs for skipping weekday checking #53

Merged
merged 1 commit into from
Jul 28, 2024
Merged

Commits on Jul 28, 2024

  1. 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.
    BurntSushi committed Jul 28, 2024
    Configuration menu
    Copy the full SHA
    7e1c54a View commit details
    Browse the repository at this point in the history