From d3c2c83b30d43ca0433aaa2bdfa5cbd3c6f800e8 Mon Sep 17 00:00:00 2001 From: Anas Awadalla Date: Sat, 26 Sep 2026 07:19:14 +0300 Subject: [PATCH 1/3] fix(weekday): accept a period after abbreviated weekday names --- src/items/weekday.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/items/weekday.rs b/src/items/weekday.rs index 77d0cc9..1efe52f 100644 --- a/src/items/weekday.rs +++ b/src/items/weekday.rs @@ -70,7 +70,7 @@ pub(super) fn parse(input: &mut &str) -> ModalResult { } fn day(input: &mut &str) -> ModalResult { - s(alpha1) + s((alpha1, opt('.')).take()) .verify_map(|s: &str| { Some(match s { "monday" | "mon" | "mon." => Day::Monday, From 2c0f68d000d4339f084c6eeb49980f9c789a9618 Mon Sep 17 00:00:00 2001 From: Anas Awadalla Date: Sun, 27 Sep 2026 05:10:33 +0300 Subject: [PATCH 2/3] test(weekday): parse abbreviated weekdays with a period through the full parser --- src/lib.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 86d8ca3..22cbdb2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -535,6 +535,33 @@ mod tests { "2023-04-24 00:00:00 000000000" ); } + + #[test] + fn test_weekday_abbreviation_with_period() { + + let date = "2023-02-28 10:12:03" + .parse::() + .unwrap() + .to_zoned(TimeZone::system()) + .unwrap(); + + for (weekday, expected) in [ + ("mon.", "2023-03-06 00:00:00 000000000"), + ("tue.", "2023-02-28 00:00:00 000000000"), + ("wed.", "2023-03-01 00:00:00 000000000"), + ("thu.", "2023-03-02 00:00:00 000000000"), + ("fri.", "2023-03-03 00:00:00 000000000"), + ("sat.", "2023-03-04 00:00:00 000000000"), + ("sun.", "2023-03-05 00:00:00 000000000"), + ] { + assert_eq!(get_formatted_date(&date, weekday), expected, "{weekday}"); + } + + let actual = crate::parse_datetime("wed., 2024-01-03") + .unwrap() + .expect_in_range(); + assert_eq!(actual.strftime("%F %T").to_string(), "2024-01-03 00:00:00"); + } } #[cfg(test)] From 6943f5dda22e3267ccea595c6b87baa23d982b77 Mon Sep 17 00:00:00 2001 From: Anas Awadalla Date: Sun, 11 Oct 2026 13:59:42 +0300 Subject: [PATCH 3/3] test(weekday): cover mismatched abbreviated weekday with period --- src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 22cbdb2..96a3962 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -538,7 +538,6 @@ mod tests { #[test] fn test_weekday_abbreviation_with_period() { - let date = "2023-02-28 10:12:03" .parse::() .unwrap() @@ -557,10 +556,13 @@ mod tests { assert_eq!(get_formatted_date(&date, weekday), expected, "{weekday}"); } - let actual = crate::parse_datetime("wed., 2024-01-03") - .unwrap() - .expect_in_range(); - assert_eq!(actual.strftime("%F %T").to_string(), "2024-01-03 00:00:00"); + for (input, expected) in [ + ("wed., 2024-01-03", "2024-01-03 00:00:00"), + ("mon., 2024-01-03", "2024-01-03 00:00:00"), + ] { + let actual = crate::parse_datetime(input).unwrap().expect_in_range(); + assert_eq!(actual.strftime("%F %T").to_string(), expected, "{input}"); + } } }