Expand description
Flexible, dependency-free date parsing shared by the feed and sitemap post-processing plugins.
Issue #586 / v0.0.47 plan §2 item 1.4 (spec A4): the native
rss.rs, atom.rs, json_feed.rs, news_sitemap.rs, and
sitemap.rs plugins each used to parse dates independently, and
only understood RFC 2822. Front matter written as July 1, 2026
or 2026-07-01 fell through and produced the upstream
'day' component could not be parsed warning spam. This module
is the single parsing chain they all share.
parse_flexible_date accepts, in priority order:
- RFC 2822 —
Wed, 01 Jul 2026 07:07:07 +0000(weekday optional and not verified, matching the lenient behaviour the plugins already relied on; seconds optional; named zones from the RFC 2822 obsolete table accepted). - Long form —
July 1, 2026and1 July 2026(full month names or three-letter abbreviations; midnight UTC assumed). - ISO 8601 date —
2026-07-01(midnight UTC assumed). - ISO 8601 datetime —
2026-07-01T07:07:07Z, withZ,±hh:mm, or±hhmmoffsets (UTC assumed when absent).
Everything is hand-rolled — month-name tables, leap-year aware day validation, timezone offset parsing — so no new dependency is introduced. Parsing is fully deterministic: no locale lookups and no system-time reads.
The output side offers the exact shapes the plugins emit today:
FlexibleDate::to_rfc2822 for RSS <pubDate>,
FlexibleDate::to_rfc3339 / FlexibleDate::to_w3c_date for
Atom <updated> and the news-sitemap <news:publication_date>,
and FlexibleDate::to_iso_date for sitemap <lastmod>.
Structs§
- Date
Parse Error - Error for input that matched none of the supported date formats.
- Flexible
Date - A parsed calendar date-time with a fixed UTC offset.
Enums§
- Date
Format - The input format that
parse_flexible_datematched.
Constants§
- ATTEMPTED_
FORMATS - The formats attempted by
parse_flexible_date, in priority order.
Functions§
- days_
in_ month - Number of days in the given month of the given year (leap-year aware). Returns 0 for an out-of-range month.
- is_
leap_ year truefor Gregorian leap years (divisible by 4, except centuries not divisible by 400).- parse_
flexible_ date - Parse a date string, trying RFC 2822, long form, ISO 8601 date, then ISO 8601 datetime (spec A4 priority order).