diff --git a/src/template/day.rs b/src/template/day.rs index da8df0f..edbbd75 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 @@ -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("invalid day number, expecting a value between 1 and 12 (or 25 before 2025)") } }; }