| Crates.io | natural-date-parser |
| lib.rs | natural-date-parser |
| version | 0.1.3 |
| created_at | 2024-11-06 00:49:18.313596+00 |
| updated_at | 2024-11-12 11:55:40.750321+00 |
| description | A parser that converts natural language date and time expressions into Rust-compatible DateTime formats. |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1437412 |
| size | 101,247 |
Name: natural-date-parser
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 rules:
date_expression = { SOI ~ (relative_day_and_specific_time | relative_date | relative_term | specific_day_and_time | specific_day | specific_time | future_time ) ~ EOI }
relative_day_and_specific_time = { ( relative_date | relative_term ) ~ "at" ~ specific_time }
relative_date = { next_or_last ~ specific_day }
relative_term = { tomorrow | today | yesterday }
specific_day_and_time = { specific_day ~ "at" ~ specific_time }
specific_day = { monday | tuesday | wednesday | thursday | friday | saturday | sunday }
specific_time = { hour ~ ":" ~ minute ~ am_pm }
future_time = { "in" ~ number ~ time_unit }
next_or_last = { next | last | this }
hour = { ASCII_DIGIT+ }
minute = { ASCII_DIGIT+ }
am_pm = { am | pm }
number = { ASCII_DIGIT+ }
time_unit = { day_s | week_s | month_s | year_s }
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
%20target(s)%20in%200.01s.png)