Skip to main content

normalize_feed_date

Function normalize_feed_date 

Source
pub fn normalize_feed_date(raw: &str) -> String
Expand description

What: Normalize a feed date string to YYYY-MM-DD.

Inputs:

  • raw: Date string in RFC 2822 (RSS), RFC 3339/ISO 8601 (Atom), or already-normalized YYYY-MM-DD form.

Output:

  • YYYY-MM-DD string on successful parse; otherwise the input with time and timezone components stripped best-effort.

Details:

  • Ported from Pacsea’s strip_time_and_tz().
  • Normalized dates sort lexicographically, which the cutoff-date filtering in the parsers relies on.

§Example

use arch_toolkit::news::normalize_feed_date;

assert_eq!(normalize_feed_date("Thu, 21 Aug 2025 12:34:56 +0000"), "2025-08-21");
assert_eq!(normalize_feed_date("2025-12-07T14:00:00Z"), "2025-12-07");
assert_eq!(normalize_feed_date("2025-12-07"), "2025-12-07");