human-chrono-parser 0.0.1

Parse human-written relative dates like "today" ,"tomorrow", "in 3 days", "next monday" and other variants.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use chrono::{Days, NaiveDate};
use human_chrono_parser::{locales::pt_br::HumanDateParserBrazillianPortuguese, HumanDateParser};

fn main() {
    let now = NaiveDate::from_ymd_opt(2024, 8, 13).unwrap(); // Example: Tuesday, August 13, 2024

    let tommorow = HumanDateParserBrazillianPortuguese::parse_relative("amanhã", now);
    println!("{:?}", tommorow);
    // outputs: Some(2024-08-14)

    assert_eq!(tommorow, now.checked_add_days(Days::new(1)));
}