1 unstable release
0.0.1 | Aug 10, 2024 |
---|
#46 in #date-parser
17KB
343 lines
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.
Dependencies
~2MB
~33K SLoC