# Cargo.toml
[package]
name = "time-test"
version = "0.1.0"
edition = "2021"
[dependencies]
time = { version = "0.3.34", features = ["parsing"] }
// src/main.rs
use time::{format_description::well_known::Rfc2822, OffsetDateTime};
fn main() {
// ok
OffsetDateTime::parse("Sat, 12 Jun 1993 13:25:19 GMT", &Rfc2822).unwrap();
// thread 'main' panicked at src/main.rs:6:65:
// called `Result::unwrap()` on an `Err` value: ParseFromDescription(InvalidComponent("weekday"))
OffsetDateTime::parse("12 Jun 1993 13:25:19 GMT", &Rfc2822).unwrap();
}
Given the following project:
According to the rfc: https://datatracker.ietf.org/doc/html/rfc2822#section-3.3 Or the rfc 5322 which made rfc2822 obsolete https://datatracker.ietf.org/doc/html/rfc5322#section-3.3
The abnf syntax is:
I suppose your implementation make
weekday
require where it should be optional.