From 4857262b4f90491e9016c2861708bd571949ad45 Mon Sep 17 00:00:00 2001 From: dfhoughton Date: Sun, 27 Jan 2019 13:45:31 -0500 Subject: added ordinals in a_date pattern --- CHANGES.md | 4 +- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 + src/lib.rs | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- tests/tests.rs | 76 +++++++++++++++++++ 6 files changed, 301 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8247ba7..4e5ee4d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,4 +9,6 @@ ## 1.0.2 * added `msg` method to `TimeError` ## 1.0.3 -* fixed "12 pm" bug \ No newline at end of file +* fixed "12 pm" bug +## 1.0.4 +* added `` pattern \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a54b044..a061ae6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,7 +108,7 @@ dependencies = [ [[package]] name = "two_timer" -version = "1.0.3" +version = "1.0.4" dependencies = [ "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e796b51..1a2661c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "two_timer" -version = "1.0.3" +version = "1.0.4" authors = ["dfhoughton "] description="parser for English time expressions" homepage="https://github.com/dfhoughton/two-timer" diff --git a/README.md b/README.md index b30a454..1d66278 100644 --- a/README.md +++ b/README.md @@ -22,5 +22,7 @@ Some expressions it can handle: * 1960-05-06 * 5000BCE * next weekend +* 2000 +* the nineteenth of March 1810 The complete API is available at https://docs.rs/two_timer/0.1.0/two_timer/. diff --git a/src/lib.rs b/src/lib.rs index c540152..7e380af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -203,7 +203,7 @@ lazy_static! { through => [["up through", "through", "thru"]] | r("-+") moment_or_period => | period => | - specific_period => | + specific_period => | | month_and_year -> named_period => | modified_period -> @@ -216,6 +216,18 @@ lazy_static! { relative_day => adverb => [["now", "today", "tomorrow", "yesterday"]] date_with_year => | + + n_date -> r("[./-]") r("[./-]") + n_date -> r("[./-]") r("[./-]") + n_date -> r("[./-]") r("[./-]") + n_date -> r("[./-]") r("[./-]") + + a_date -> ? (",") + a_date -> ? + a_date -> ? ("the") ("of") + + day_prefix => (",") + o_n_day => | at_time -> ("at")