summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md4
-rw-r--r--tests/tests.rs67
2 files changed, 70 insertions, 1 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 4e5ee4d..8e12b1b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -11,4 +11,6 @@
## 1.0.3
* fixed "12 pm" bug
## 1.0.4
-* added `<year>` pattern \ No newline at end of file
+* added `<year>` pattern
+* added ordinals for days of the month
+* added kalends, nones, ides \ No newline at end of file
diff --git a/tests/tests.rs b/tests/tests.rs
index bd39a70..5f9494a 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1130,3 +1130,70 @@ fn ordinals() {
}
}
}
+
+#[test]
+fn kalends_nones_ids() {
+ let months = [
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December",
+ ];
+ for (i, m) in months.iter().enumerate() {
+ let i = (i + 1) as u32;
+ let big_month = match i {
+ 3 | 5 | 7 | 10 => true,
+ _ => false,
+ };
+ // kalends
+ let d1 = NaiveDate::from_ymd(2018, i, 1).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the kalends of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ // nones
+ let d1 = NaiveDate::from_ymd(2018, i, if big_month { 7 } else { 5 }).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the nones of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ // ides
+ let d1 = NaiveDate::from_ymd(2018, i, if big_month { 15 } else { 13 }).and_hms(0, 0, 0);
+ let d2 = d1 + Duration::days(1);
+ let p = format!("the ides of {} 2018", m);
+ match parse(&p, None) {
+ Ok((start, end, _)) => {
+ assert_eq!(d1, start);
+ assert_eq!(d2, end);
+ }
+ Err(e) => {
+ println!("{:?}", e);
+ assert!(false, "didn't match");
+ }
+ }
+ }
+}