From 116fd7a2a56a3788ffc9269054b395b7a6d45235 Mon Sep 17 00:00:00 2001 From: Anas Awadalla Date: Sat, 26 Sep 2026 07:19:14 +0300 Subject: [PATCH 1/2] 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 1fae3fde40a5cb271fc7449fc9746275e0868fdd Mon Sep 17 00:00:00 2001 From: Anas Awadalla Date: Sun, 27 Sep 2026 05:10:33 +0300 Subject: [PATCH 2/2] 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 128baa9..fbb6c71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -521,6 +521,33 @@ mod tests { "2023-03-05 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)]