Expand description
§FuzzyDate: Date Input for Humans
A Parser which can turn a variety of input strings into a DateTime
§Usage
Put this in your Cargo.toml:
fuzzydate = "0.2"§Example
use fuzzydate::parse;
use chrono::{NaiveDateTime};
fn main() {
let date_string = "Five days after 2/12/22 5:00 PM";
let date = parse(date_string).unwrap();
println!("{:?}", date);
}Any relevant date time information not specified is assumed to be the value of the current date time.
§Grammar
<datetime> ::= <time>
| <time> , <date>
| <time> <date>
| <time> on <date>
| <date>
| <date> <time>
| <date> , <time>
| <date> at <time>
| <duration> after <datetime>
| <duration> from <datetime>
| <duration> before <datetime>
| <duration> ago
| now
<date> ::= today
| tomorrow
| yesterday
| <num> / <num> / <num>
| <num> - <num> - <num>
| <num> . <num> . <num>
| <month> <num> <num>
| <duration> ago ; duration must be for a whole number of days
| <duration> after <date>
| <duration> from <date>
| <duration> before <date>
| <relative_specifier> <weekday>
| <relative_specifier> <unit>
| <weekday>
<time> ::= <num>
| <num>:<num>
| <num>:<num> am
| <num>:<num> pm
| <num>
| <num> am
| <num> pm
| <num> <num> am
| <num> <num> pm
| midnight
| noon
<duration> ::= <num> <unit>
| <article> <unit>
| <duration> and <duration>
<article> ::= a
| an
| the
<relative_specifier> ::= this
| next
| last
<weekday> ::= monday
| tuesday
| wednesday
| thursday
| friday
| saturday
| sunday
| mon
| tue
| wed
| thu
| fri
| sat
| sun
<month> ::= january
| february
| march
| april
| may
| june
| july
| august
| september
| october
| november
| december
| jan
| feb
| mar
| apr
| jun
| jul
| aug
| sep
| oct
| nov
| dec
<unit> ::= day
| days
| week
| weeks
| hour
| hours
| minute
| minutes
| min
| mins
| month
| months
| year
| years
<num> ::= <num_triple> <num_triple_unit> and <num>
| <num_triple> <num_triple_unit> <num>
| <num_triple> <num_triple_unit>
| <num_triple_unit> and <num>
| <num_triple_unit> <num>
| <num_triple_unit>
| <num_triple>
| NUM ; number literal greater than or equal to 1000
<num_triple> ::= <ones> hundred and <num_double>
| <ones> hundred <num_double>
| <ones> hundred
| hundred and <num_double>
| hundred <num_double>
| hundred
| <num_double>
| NUM ; number literal less than 1000 and greater than 99
<num_triple_unit> ::= thousand
| million
| billion
<num_double> ::= <ones>
| <tens> - <ones>
| <tens> <ones>
| <tens>
| <teens>
| NUM ; number literal less than 100 and greater than 19
<tens> ::= twenty
| thirty
| forty
| fifty
| sixty
| seventy
| eighty
| ninety
<teens> ::= ten
| eleven
| twelve
| thirteen
| fourteen
| fifteen
| sixteen
| seventeen
| eighteen
| nineteen
| NUM ; number literal less than 20 and greater than 9
<ones> ::= one
| two
| three
| four
| five
| six
| seven
| eight
| nine
| NUM ; number literal less than 10Enums§
Functions§
- aware_
parse - Parse an input string into a timezone-aware chrono DateTime using the given time and timezone.
- debug_
parse - Parse an input string into a chrono DateTime with the given default time. Defaults to None if not given. Time is parsed and returned in the given timezone. Returns all stages of parsing for debugging
- parse
- Parse an input string into a chrono NaiveDateTime using the system local time for any missing values.
- parse_
relative_ to - Parse an input string into a chrono NaiveDateTime, using relative_to as the current time.
- parse_
with_ default_ time Deprecated - Parse an input string into a chrono NaiveDateTime, using the default values from the specified default value where not specified