Crates.io | human-chrono-parser |
lib.rs | human-chrono-parser |
version | 0.0.1 |
source | src |
created_at | 2024-08-10 03:41:35.655924 |
updated_at | 2024-08-10 03:41:35.655924 |
description | Parse human-written relative dates like "today" ,"tomorrow", "in 3 days", "next monday" and other variants. |
homepage | |
repository | https://github.com/ecarrara/human-chrono-parser |
max_upload_size | |
id | 1331960 |
size | 25,616 |
Parse human-written relative dates like "today" ,"tomorrow", "in 3 days", "next monday" and other variants.
To use the human-chrono-parser
in your project, include it in your
Cargo.toml
:
[dependencies]
human-chrono-parser = "0.0.1"
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)));
}
Currently only pt-BR locale is supported. We welcome contributions to support other locales!
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.