parse_rfc2822_date

Function parse_rfc2822_date 

Source
pub fn parse_rfc2822_date(
    input: &str,
) -> Result<DateTime<FixedOffset>, ParseError>
Expand description

Parse an RFC 2822 date-time, tolerating obsolete alphabetic time zones.

chrono’s parse_from_rfc2822 accepts the zone tokens named in RFC 5322 section 4.3 (UT, GMT, the North American EST/EDT/… set) but rejects any other alphabetic zone. Real senders still emit some: Amazon SES writes its DSN dates with the token UTC, which chrono does not recognize.

When the strict parse fails we retry after replacing a trailing alphabetic zone token with a numeric offset. A token with a single widely-agreed meaning (UTC, and the common regional abbreviations chrono lacks such as CET/CEST) resolves to its real offset. Anything chrono neither knows nor we can resolve unambiguously falls back to -0000, the RFC 5322 section 4.3 unknown-offset marker: the same instant as UTC, which keeps the stated wall-clock date and time while recording that the true offset is unknown. The original error is preserved when the retry does not help, so genuinely malformed input still reports the real problem rather than a zone complaint.