From 0e01d76142370356341bce74143313ee7e5c293d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Weis?= Date: Sun, 7 Dec 2025 13:57:10 +0100 Subject: [PATCH 1/3] Fixup month number 12 --- src/template/day.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template/day.rs b/src/template/day.rs index da8df0f..582c506 100644 --- a/src/template/day.rs +++ b/src/template/day.rs @@ -54,7 +54,7 @@ impl Day { pub fn today() -> Option { let offset = FixedOffset::east_opt(SERVER_UTC_OFFSET * 3600)?; let today = Utc::now().with_timezone(&offset); - if today.month() == day_count!() as u32 && today.day() <= day_count!() as u32 { + if today.month() == 12 && today.day() <= day_count!() as u32 { Self::new(u8::try_from(today.day()).ok()?) } else { None From a64956d8ea0f3aa19f704f63aad77133d8166714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Weis?= Date: Sun, 7 Dec 2025 14:11:41 +0100 Subject: [PATCH 2/3] Fixup error message --- src/template/day.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/template/day.rs b/src/template/day.rs index 582c506..09d4f1e 100644 --- a/src/template/day.rs +++ b/src/template/day.rs @@ -99,18 +99,18 @@ impl Error for DayFromStrError {} impl Display for DayFromStrError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str("expecting a day number between 1 and 12") + f.write_str(&format!("expecting a day number between 1 and {}", day_count!())) } } /* -------------------------------------------------------------------------- */ -/// An iterator that yields every day of advent from the 1st to the 12th. +/// An iterator that yields every day of advent from the 1st to the 12th (or 25th before 2025). pub fn all_days() -> AllDays { AllDays::new() } -/// An iterator that yields every day of advent from the 1st to the 12th. +/// An iterator that yields every day of advent from the 1st to the 12th (or 25th before 2025). pub struct AllDays { current: u8, } @@ -129,7 +129,7 @@ impl Iterator for AllDays { if self.current > day_count!() { return None; } - // NOTE: the iterator starts at 1 and we have verified that the value is not above 12. + // NOTE: the iterator starts at 1, and we have verified that the value is not above 12 (or 25). let day = Day(self.current); self.current += 1; @@ -145,7 +145,7 @@ macro_rules! day { ($day:expr) => { const { $crate::template::Day::new($day) - .expect("invalid day number, expecting a value between 1 and 12") + .expect(&format!("invalid day number, expecting a value between 1 and {}", day_count!())) } }; } From 6b96da7092273a0179a1d30b6121f76c2fb26193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Weis?= Date: Sun, 7 Dec 2025 16:59:18 +0100 Subject: [PATCH 3/3] Use simple string literal, const str is hard --- src/template/day.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template/day.rs b/src/template/day.rs index 09d4f1e..edbbd75 100644 --- a/src/template/day.rs +++ b/src/template/day.rs @@ -145,7 +145,7 @@ macro_rules! day { ($day:expr) => { const { $crate::template::Day::new($day) - .expect(&format!("invalid day number, expecting a value between 1 and {}", day_count!())) + .expect("invalid day number, expecting a value between 1 and 12 (or 25 before 2025)") } }; }