parse_date_string

Function parse_date_string 

Source
pub fn parse_date_string<Dt: DateTime>(
    s: &str,
    now: Dt,
    dialect: Dialect,
) -> DateResult<Dt>
Expand description

Parse a date-time from the text, potentially relative to now. Accepts a Dialect to support some slightly different text parsing behaviour.

use interim::{parse_date_string, Dialect};
use chrono::{Utc, TimeZone};

let now = Utc.with_ymd_and_hms(2022, 9, 17, 13, 27, 0).unwrap();
let this_friday = parse_date_string("friday 8pm", now, Dialect::Uk).unwrap();

assert_eq!(this_friday, Utc.with_ymd_and_hms(2022, 9, 23, 20, 0, 0).unwrap());