Crates.io | nom-date-parsers |
lib.rs | nom-date-parsers |
version | 1.1.0 |
source | src |
created_at | 2024-07-17 06:11:32.141897 |
updated_at | 2024-08-08 06:06:28.74175 |
description | The bunch of combinators written with help of nom to parse the numeric and language-specific dates |
homepage | https://github.com/syrtcevvi/nom-date-parsers |
repository | https://github.com/syrtcevvi/nom-date-parsers |
max_upload_size | |
id | 1305864 |
size | 83,250 |
The bunch of combinators written with help of nom to parse the numeric
and language-specific
dates.
Currently the following languages are supported:
Russian
(ru
feature flag)English
(en
feature flag, enabled by default)This crate can be used to write other parsers or standalone to parse chrono::NaiveDate
s from strings.
This crate uses chrono::Local
type for almost all date computations.
I work on my telegram bot and provide to my users the way to get some information by the date in the format: dd-mm-yyyy. Indeed some of them get the correct format and successfully receive what they want. Others just throw something vaguely reminiscent of the date and complain that bot can't understand them. So, this crate tries to solve this problem.
The following patterns can be recognized
Instead of the /
symbol the other separators can be used:
/
-
.
It's not necessary that separators match in every place, so the dd/mm-y4
or even dd mm.y4
are acceptable formats
To parse the [chrono::NaiveDate
] value you can use the following methods:
In case of absence of any date part the corresponding date part of today is used.
Each language-specific parsers are put behind the corresponding feature flag
(ru
or en
), except the en
which is available by default.
Sometimes its cool to receive a date for a relative day
or weekday
(fully
or shortly
named):
For more info of usage see the documentation of functions