Crates.io | natural-date-parser |
lib.rs | natural-date-parser |
version | 0.1.1 |
source | src |
created_at | 2024-11-06 00:49:18.313596 |
updated_at | 2024-11-07 01:15:09.811577 |
description | A parser that converts natural language date and time expressions into Rust-compatible DateTime formats. |
homepage | |
repository | |
max_upload_size | |
id | 1437412 |
size | 381,080 |
A parser that converts natural language date and time expressions into Rust-compatible DateTime formats.
Natural Date Parser is a Rust project designed to parse human-friendly, natural language date and time expressions, such as "next Monday," "tomorrow at 5 PM," or "3 weeks from now." This parser converts these expressions into structured DateTime
objects, making them usable in scheduling applications, reminders, or other time-based software.
The parser is built using the Pest parsing library and is designed to recognize a variety of natural language phrases related to dates and times. These include:
The parsing process follows these steps:
chrono
library to calculate the exact DateTime
value.The output DateTime
values can be used in a variety of applications:
To start using Natural Date Parser, you can use crate on crates.io
fn main() -> anyhow::Result<()> {
let pair = Grammar::parse(Rule::date_expression, "next Monday")?
.next()
.ok_or_else(|| anyhow!("no pair"))?;
dbg!(pair);
Ok(())
}