Skip to main content

try_parse_date

Function try_parse_date 

Source
pub fn try_parse_date(input: &str, today: Date) -> Result<Date, DateParseError>
Expand description

Try to parse a single date string. Handles:

  • ISO dates: 2025-12-31
  • Present: today
  • Past: yesterday, last friday, 7 days ago, 7d ago, 1 week ago
  • Future: tomorrow, next monday, in 3 days, in 7d, next week, next month

Note: Year-month formats like 2025-12 are periods, not dates. Use try_parse_period instead.

ยงErrors

Returns DateParseError if the input cannot be parsed.