Function interim::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.ymd(2022, 9, 17).and_hms(13, 27, 0);
let this_friday = parse_date_string("friday 8pm", now, Dialect::Uk).unwrap();
assert_eq!(this_friday, Utc.ymd(2022, 9, 23).and_hms(20, 0, 0));