@@ -114,54 +114,6 @@ impl Calendar for Iso {
114
114
date. 0 . days_in_month ( )
115
115
}
116
116
117
- fn day_of_week ( & self , date : & Self :: DateInner ) -> types:: Weekday {
118
- // For the purposes of the calculation here, Monday is 0, Sunday is 6
119
- // ISO has Monday=1, Sunday=7, which we transform in the last step
120
-
121
- // The days of the week are the same every 400 years
122
- // so we normalize to the nearest multiple of 400
123
- let years_since_400 = date. 0 . year . rem_euclid ( 400 ) ;
124
- debug_assert ! ( years_since_400 >= 0 ) ; // rem_euclid returns positive numbers
125
- let years_since_400 = years_since_400 as u32 ;
126
- let leap_years_since_400 = years_since_400 / 4 - years_since_400 / 100 ;
127
- // The number of days to the current year
128
- // Can never cause an overflow because years_since_400 has a maximum value of 399.
129
- let days_to_current_year = 365 * years_since_400 + leap_years_since_400;
130
- // The weekday offset from January 1 this year and January 1 2000
131
- let year_offset = days_to_current_year % 7 ;
132
-
133
- // Corresponding months from
134
- // https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Corresponding_months
135
- let month_offset = if Self :: is_leap_year ( date. 0 . year , ( ) ) {
136
- match date. 0 . month {
137
- 10 => 0 ,
138
- 5 => 1 ,
139
- 2 | 8 => 2 ,
140
- 3 | 11 => 3 ,
141
- 6 => 4 ,
142
- 9 | 12 => 5 ,
143
- 1 | 4 | 7 => 6 ,
144
- _ => unreachable ! ( ) ,
145
- }
146
- } else {
147
- match date. 0 . month {
148
- 1 | 10 => 0 ,
149
- 5 => 1 ,
150
- 8 => 2 ,
151
- 2 | 3 | 11 => 3 ,
152
- 6 => 4 ,
153
- 9 | 12 => 5 ,
154
- 4 | 7 => 6 ,
155
- _ => unreachable ! ( ) ,
156
- }
157
- } ;
158
- let january_1_2000 = 5 ; // Saturday
159
- let day_offset = ( january_1_2000 + year_offset + month_offset + date. 0 . day as u32 ) % 7 ;
160
-
161
- // We calculated in a zero-indexed fashion, but ISO specifies one-indexed
162
- types:: Weekday :: from ( ( day_offset + 1 ) as usize )
163
- }
164
-
165
117
fn offset_date ( & self , date : & mut Self :: DateInner , offset : DateDuration < Self > ) {
166
118
date. 0 . offset_date ( offset, & ( ) ) ;
167
119
}
0 commit comments