1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! # timewarp
//! NLP library for parsing English and German natural language into dates and times.
//! Leverages [pest](https://pest.rs) for parsing human readable-dates and times.
//!
//!
//! Should parse
//! ```rust
//! use timewarp::Direction::*;
//! use timewarp::{date_matcher, Doy, Tempus};
//!
//! // Fri 2023-03-17
//! let today = Doy::from_ymd(2023, 3, 17);
//! // Date as used in German (d.m.y)
//! assert_eq!(
//! date_matcher(today, From, "22.1.23").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 1, 22))
//! );
//! assert_eq!(
//! date_matcher(today, From, "22.1.").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 1, 22))
//! );
//! // Date as common for english-speaker m/d/y
//! assert_eq!(
//! date_matcher(today, From, "3/16/2023").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 16))
//! );
//! // Date written in ISO
//! assert_eq!(
//! date_matcher(today, From, "2023-03-16").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 16))
//! );
//!
//! assert_eq!(
//! date_matcher(today, To, "last monday").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 13))
//! );
//! assert_eq!(
//! date_matcher(today, From, "tuesday").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 14))
//! );
//! assert_eq!(
//! date_matcher(today, To, "tuesday").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 21))
//! );
//! assert_eq!(
//! date_matcher(today, From, "letzten donnerstag").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 16))
//! );
//! assert_eq!(
//! date_matcher(today, To, "last friday").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 10))
//! );
//! assert_eq!(
//! date_matcher(today, To, "nächsten Fr").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 24))
//! );
//! assert_eq!(
//! date_matcher(today, To, "coming Thu").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 23))
//! );
//! assert_eq!(
//! date_matcher(today, To, "übernächsten Donnerstag").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 30))
//! );
//! assert_eq!(
//! date_matcher(today, To, "nächster Mo").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 20))
//! );
//! assert_eq!(
//! date_matcher(today, To, "vorletzter mo").unwrap(),
//! Tempus::Moment(Doy::from_ymd(2023, 3, 6))
//! );
//! ```
extern crate pest_derive;
pub use ;
pub use DayOfWeek;
pub use ;
pub use TimeWarpError;
pub use Month;