human-chrono-parser

Crates.iohuman-chrono-parser
lib.rshuman-chrono-parser
version0.0.1
sourcesrc
created_at2024-08-10 03:41:35.655924
updated_at2024-08-10 03:41:35.655924
descriptionParse human-written relative dates like "today" ,"tomorrow", "in 3 days", "next monday" and other variants.
homepage
repositoryhttps://github.com/ecarrara/human-chrono-parser
max_upload_size
id1331960
size25,616
Erle Carrara (ecarrara)

documentation

README

human-chrono-parser

Parse human-written relative dates like "today" ,"tomorrow", "in 3 days", "next monday" and other variants.

Installation

To use the human-chrono-parser in your project, include it in your Cargo.toml:

[dependencies]
human-chrono-parser = "0.0.1"

Usage

Here is a basic example of how to use the HumanDateParser trait:

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); // Some(2024-08-14)

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

Locales

Currently only pt-BR locale is supported. We welcome contributions to support other locales!

Contributing

Contributions are welcome! If you'd like to improve the library or add more features, please open an issue, fork the repository and create a pull request.

Commit count: 0

cargo fmt