@@ -141,8 +141,8 @@ impl Date {
141141 return Err ( error:: ComponentRange {
142142 name : "day" ,
143143 minimum : 1 ,
144- maximum : month. length ( year) as _ ,
145- value : day as _ ,
144+ maximum : month. length ( year) as i64 ,
145+ value : day as i64 ,
146146 conditional_message : Some ( "for the given month and year" ) ,
147147 } ) ;
148148 }
@@ -179,8 +179,8 @@ impl Date {
179179 return Err ( error:: ComponentRange {
180180 name : "ordinal" ,
181181 minimum : 1 ,
182- maximum : days_in_year ( year) as _ ,
183- value : ordinal as _ ,
182+ maximum : days_in_year ( year) as i64 ,
183+ value : ordinal as i64 ,
184184 conditional_message : Some ( "for the given year" ) ,
185185 } ) ;
186186 }
@@ -216,8 +216,8 @@ impl Date {
216216 return Err ( error:: ComponentRange {
217217 name : "week" ,
218218 minimum : 1 ,
219- maximum : weeks_in_year ( year) as _ ,
220- value : week as _ ,
219+ maximum : weeks_in_year ( year) as i64 ,
220+ value : week as i64 ,
221221 conditional_message : Some ( "for the given year" ) ,
222222 } ) ;
223223 }
@@ -252,7 +252,7 @@ impl Date {
252252 }
253253 } else {
254254 // Safety: `ordinal` is not zero.
255- unsafe { Self :: __from_ordinal_date_unchecked ( year, ordinal as _ ) }
255+ unsafe { Self :: __from_ordinal_date_unchecked ( year, ordinal as u16 ) }
256256 } )
257257 }
258258
@@ -316,7 +316,7 @@ impl Date {
316316
317317 // Safety: `ordinal` is not zero and `is_leap_year` is correct, so long as the Julian day
318318 // number is in range.
319- unsafe { Self :: from_parts ( y_g, is_leap_year, ordinal as _ ) }
319+ unsafe { Self :: from_parts ( y_g, is_leap_year, ordinal as u16 ) }
320320 }
321321
322322 /// Whether `is_leap_year(self.year())` is `true`.
@@ -391,7 +391,7 @@ impl Date {
391391 let ordinal = ordinal - ordinal_adj;
392392 let month = ( ordinal * 268 + 8031 ) >> 13 ;
393393 let days_in_preceding_months = ( month * 3917 - 3866 ) >> 7 ;
394- ( ordinal - days_in_preceding_months) as _
394+ ( ordinal - days_in_preceding_months) as u8
395395 }
396396
397397 /// Get the day of the year.
@@ -404,14 +404,14 @@ impl Date {
404404 /// assert_eq!(date!(2019-12-31).ordinal(), 365);
405405 /// ```
406406 pub const fn ordinal ( self ) -> u16 {
407- ( self . value . get ( ) & 0x1FF ) as _
407+ ( self . value . get ( ) & 0x1FF ) as u16
408408 }
409409
410410 /// Get the ISO 8601 year and week number.
411411 pub ( crate ) const fn iso_year_week ( self ) -> ( i32 , u8 ) {
412412 let ( year, ordinal) = self . to_ordinal_date ( ) ;
413413
414- match ( ( ordinal + 10 - self . weekday ( ) . number_from_monday ( ) as u16 ) / 7 ) as _ {
414+ match ( ( ordinal + 10 - self . weekday ( ) . number_from_monday ( ) as u16 ) / 7 ) as u8 {
415415 0 => ( year - 1 , weeks_in_year ( year - 1 ) ) ,
416416 53 if weeks_in_year ( year) == 52 => ( year + 1 , 1 ) ,
417417 week => ( year, week) ,
@@ -446,7 +446,7 @@ impl Date {
446446 /// assert_eq!(date!(2021-01-01).sunday_based_week(), 0);
447447 /// ```
448448 pub const fn sunday_based_week ( self ) -> u8 {
449- ( ( self . ordinal ( ) as i16 - self . weekday ( ) . number_days_from_sunday ( ) as i16 + 6 ) / 7 ) as _
449+ ( ( self . ordinal ( ) as i16 - self . weekday ( ) . number_days_from_sunday ( ) as i16 + 6 ) / 7 ) as u8
450450 }
451451
452452 /// Get the week number where week 1 begins on the first Monday.
@@ -461,7 +461,7 @@ impl Date {
461461 /// assert_eq!(date!(2021-01-01).monday_based_week(), 0);
462462 /// ```
463463 pub const fn monday_based_week ( self ) -> u8 {
464- ( ( self . ordinal ( ) as i16 - self . weekday ( ) . number_days_from_monday ( ) as i16 + 6 ) / 7 ) as _
464+ ( ( self . ordinal ( ) as i16 - self . weekday ( ) . number_days_from_monday ( ) as i16 + 6 ) / 7 ) as u8
465465 }
466466
467467 /// Get the year, month, and day.
@@ -529,7 +529,7 @@ impl Date {
529529 let ( year, ordinal) = self . to_ordinal_date ( ) ;
530530 let weekday = self . weekday ( ) ;
531531
532- match ( ( ordinal + 10 - weekday. number_from_monday ( ) as u16 ) / 7 ) as _ {
532+ match ( ( ordinal + 10 - weekday. number_from_monday ( ) as u16 ) / 7 ) as u8 {
533533 0 => ( year - 1 , weeks_in_year ( year - 1 ) , weekday) ,
534534 53 if weeks_in_year ( year) == 52 => ( year + 1 , 1 , weekday) ,
535535 week => ( year, week, weekday) ,
@@ -779,7 +779,7 @@ impl Date {
779779 return None ;
780780 }
781781
782- let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_add( whole_days as _ ) ) ;
782+ let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_add( whole_days as i32 ) ) ;
783783 if let Ok ( date) = Self :: from_julian_day ( julian_day) {
784784 Some ( date)
785785 } else {
@@ -822,7 +822,7 @@ impl Date {
822822 return None ;
823823 }
824824
825- let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_add( whole_days as _ ) ) ;
825+ let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_add( whole_days as i32 ) ) ;
826826 if let Ok ( date) = Self :: from_julian_day ( julian_day) {
827827 Some ( date)
828828 } else {
@@ -867,7 +867,7 @@ impl Date {
867867 return None ;
868868 }
869869
870- let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_sub( whole_days as _ ) ) ;
870+ let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_sub( whole_days as i32 ) ) ;
871871 if let Ok ( date) = Self :: from_julian_day ( julian_day) {
872872 Some ( date)
873873 } else {
@@ -910,7 +910,7 @@ impl Date {
910910 return None ;
911911 }
912912
913- let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_sub( whole_days as _ ) ) ;
913+ let julian_day = const_try_opt ! ( self . to_julian_day( ) . checked_sub( whole_days as i32 ) ) ;
914914 if let Ok ( date) = Self :: from_julian_day ( julian_day) {
915915 Some ( date)
916916 } else {
@@ -1141,8 +1141,8 @@ impl Date {
11411141 return Err ( error:: ComponentRange {
11421142 name : "day" ,
11431143 minimum : 1 ,
1144- maximum : self . month ( ) . length ( self . year ( ) ) as _ ,
1145- value : day as _ ,
1144+ maximum : self . month ( ) . length ( self . year ( ) ) as i64 ,
1145+ value : day as i64 ,
11461146 conditional_message : Some ( "for the given month and year" ) ,
11471147 } ) ;
11481148 }
@@ -1152,7 +1152,7 @@ impl Date {
11521152 Ok ( unsafe {
11531153 Self :: __from_ordinal_date_unchecked (
11541154 self . year ( ) ,
1155- ( self . ordinal ( ) as i16 - self . day ( ) as i16 + day as i16 ) as _ ,
1155+ ( self . ordinal ( ) as i16 - self . day ( ) as i16 + day as i16 ) as u16 ,
11561156 )
11571157 } )
11581158 }
@@ -1174,8 +1174,8 @@ impl Date {
11741174 return Err ( error:: ComponentRange {
11751175 name : "ordinal" ,
11761176 minimum : 1 ,
1177- maximum : days_in_year ( self . year ( ) ) as _ ,
1178- value : ordinal as _ ,
1177+ maximum : days_in_year ( self . year ( ) ) as i64 ,
1178+ value : ordinal as i64 ,
11791179 conditional_message : Some ( "for the given year" ) ,
11801180 } ) ;
11811181 }
0 commit comments