@@ -54,7 +54,7 @@ impl Day {
5454 pub fn today ( ) -> Option < Self > {
5555 let offset = FixedOffset :: east_opt ( SERVER_UTC_OFFSET * 3600 ) ?;
5656 let today = Utc :: now ( ) . with_timezone ( & offset) ;
57- if today. month ( ) == day_count ! ( ) as u32 && today. day ( ) <= day_count ! ( ) as u32 {
57+ if today. month ( ) == 12 && today. day ( ) <= day_count ! ( ) as u32 {
5858 Self :: new ( u8:: try_from ( today. day ( ) ) . ok ( ) ?)
5959 } else {
6060 None
@@ -99,18 +99,18 @@ impl Error for DayFromStrError {}
9999
100100impl Display for DayFromStrError {
101101 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
102- f. write_str ( "expecting a day number between 1 and 12" )
102+ f. write_str ( & format ! ( "expecting a day number between 1 and {}" , day_count! ( ) ) )
103103 }
104104}
105105
106106/* -------------------------------------------------------------------------- */
107107
108- /// An iterator that yields every day of advent from the 1st to the 12th.
108+ /// An iterator that yields every day of advent from the 1st to the 12th (or 25th before 2025) .
109109pub fn all_days ( ) -> AllDays {
110110 AllDays :: new ( )
111111}
112112
113- /// An iterator that yields every day of advent from the 1st to the 12th.
113+ /// An iterator that yields every day of advent from the 1st to the 12th (or 25th before 2025) .
114114pub struct AllDays {
115115 current : u8 ,
116116}
@@ -129,7 +129,7 @@ impl Iterator for AllDays {
129129 if self . current > day_count ! ( ) {
130130 return None ;
131131 }
132- // NOTE: the iterator starts at 1 and we have verified that the value is not above 12.
132+ // NOTE: the iterator starts at 1, and we have verified that the value is not above 12 (or 25) .
133133 let day = Day ( self . current ) ;
134134 self . current += 1 ;
135135
@@ -145,7 +145,7 @@ macro_rules! day {
145145 ( $day: expr) => {
146146 const {
147147 $crate:: template:: Day :: new( $day)
148- . expect( "invalid day number, expecting a value between 1 and 12" )
148+ . expect( "invalid day number, expecting a value between 1 and 12 (or 25 before 2025) " )
149149 }
150150 } ;
151151}
0 commit comments