@@ -141,8 +141,8 @@ impl Date {
141
141
return Err ( error:: ComponentRange {
142
142
name : "day" ,
143
143
minimum : 1 ,
144
- maximum : month. length ( year) as _ ,
145
- value : day as _ ,
144
+ maximum : month. length ( year) as i64 ,
145
+ value : day as i64 ,
146
146
conditional_message : Some ( "for the given month and year" ) ,
147
147
} ) ;
148
148
}
@@ -179,8 +179,8 @@ impl Date {
179
179
return Err ( error:: ComponentRange {
180
180
name : "ordinal" ,
181
181
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 ,
184
184
conditional_message : Some ( "for the given year" ) ,
185
185
} ) ;
186
186
}
@@ -216,8 +216,8 @@ impl Date {
216
216
return Err ( error:: ComponentRange {
217
217
name : "week" ,
218
218
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 ,
221
221
conditional_message : Some ( "for the given year" ) ,
222
222
} ) ;
223
223
}
@@ -252,7 +252,7 @@ impl Date {
252
252
}
253
253
} else {
254
254
// 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 ) }
256
256
} )
257
257
}
258
258
@@ -316,7 +316,7 @@ impl Date {
316
316
317
317
// Safety: `ordinal` is not zero and `is_leap_year` is correct, so long as the Julian day
318
318
// 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 ) }
320
320
}
321
321
322
322
/// Whether `is_leap_year(self.year())` is `true`.
@@ -391,7 +391,7 @@ impl Date {
391
391
let ordinal = ordinal - ordinal_adj;
392
392
let month = ( ordinal * 268 + 8031 ) >> 13 ;
393
393
let days_in_preceding_months = ( month * 3917 - 3866 ) >> 7 ;
394
- ( ordinal - days_in_preceding_months) as _
394
+ ( ordinal - days_in_preceding_months) as u8
395
395
}
396
396
397
397
/// Get the day of the year.
@@ -404,14 +404,14 @@ impl Date {
404
404
/// assert_eq!(date!(2019-12-31).ordinal(), 365);
405
405
/// ```
406
406
pub const fn ordinal ( self ) -> u16 {
407
- ( self . value . get ( ) & 0x1FF ) as _
407
+ ( self . value . get ( ) & 0x1FF ) as u16
408
408
}
409
409
410
410
/// Get the ISO 8601 year and week number.
411
411
pub ( crate ) const fn iso_year_week ( self ) -> ( i32 , u8 ) {
412
412
let ( year, ordinal) = self . to_ordinal_date ( ) ;
413
413
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 {
415
415
0 => ( year - 1 , weeks_in_year ( year - 1 ) ) ,
416
416
53 if weeks_in_year ( year) == 52 => ( year + 1 , 1 ) ,
417
417
week => ( year, week) ,
@@ -446,7 +446,7 @@ impl Date {
446
446
/// assert_eq!(date!(2021-01-01).sunday_based_week(), 0);
447
447
/// ```
448
448
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
450
450
}
451
451
452
452
/// Get the week number where week 1 begins on the first Monday.
@@ -461,7 +461,7 @@ impl Date {
461
461
/// assert_eq!(date!(2021-01-01).monday_based_week(), 0);
462
462
/// ```
463
463
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
465
465
}
466
466
467
467
/// Get the year, month, and day.
@@ -529,7 +529,7 @@ impl Date {
529
529
let ( year, ordinal) = self . to_ordinal_date ( ) ;
530
530
let weekday = self . weekday ( ) ;
531
531
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 {
533
533
0 => ( year - 1 , weeks_in_year ( year - 1 ) , weekday) ,
534
534
53 if weeks_in_year ( year) == 52 => ( year + 1 , 1 , weekday) ,
535
535
week => ( year, week, weekday) ,
@@ -779,7 +779,7 @@ impl Date {
779
779
return None ;
780
780
}
781
781
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 ) ) ;
783
783
if let Ok ( date) = Self :: from_julian_day ( julian_day) {
784
784
Some ( date)
785
785
} else {
@@ -822,7 +822,7 @@ impl Date {
822
822
return None ;
823
823
}
824
824
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 ) ) ;
826
826
if let Ok ( date) = Self :: from_julian_day ( julian_day) {
827
827
Some ( date)
828
828
} else {
@@ -867,7 +867,7 @@ impl Date {
867
867
return None ;
868
868
}
869
869
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 ) ) ;
871
871
if let Ok ( date) = Self :: from_julian_day ( julian_day) {
872
872
Some ( date)
873
873
} else {
@@ -910,7 +910,7 @@ impl Date {
910
910
return None ;
911
911
}
912
912
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 ) ) ;
914
914
if let Ok ( date) = Self :: from_julian_day ( julian_day) {
915
915
Some ( date)
916
916
} else {
@@ -1141,8 +1141,8 @@ impl Date {
1141
1141
return Err ( error:: ComponentRange {
1142
1142
name : "day" ,
1143
1143
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 ,
1146
1146
conditional_message : Some ( "for the given month and year" ) ,
1147
1147
} ) ;
1148
1148
}
@@ -1152,7 +1152,7 @@ impl Date {
1152
1152
Ok ( unsafe {
1153
1153
Self :: __from_ordinal_date_unchecked (
1154
1154
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 ,
1156
1156
)
1157
1157
} )
1158
1158
}
@@ -1174,8 +1174,8 @@ impl Date {
1174
1174
return Err ( error:: ComponentRange {
1175
1175
name : "ordinal" ,
1176
1176
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 ,
1179
1179
conditional_message : Some ( "for the given year" ) ,
1180
1180
} ) ;
1181
1181
}
0 commit comments