Skip to main content

parse_range

Function parse_range 

Source
pub fn parse_range(input: &str) -> Result<(DateTime<Local>, DateTime<Local>)>
Expand description

Parse a date range expression into a (start, end) tuple of DateTime<Local>.

Supports range separators: to, through, thru, until, til, and --/-. Each side of the range is parsed as a natural language date expression via chronify.

When given a single date (no range separator), returns a 24-hour span from the start of that day to start of the next day.

ยงExamples

  • "monday to friday"
  • "yesterday to today"
  • "2024-01-01 through 2024-01-31"
  • "last monday to next friday"
  • "yesterday" (returns yesterday 00:00:00 to today 00:00:00)
  • "2024-01-15" (returns 2024-01-15 00:00:00 to 2024-01-16 00:00:00)