@@ -72,7 +72,7 @@ pub const fn days_in_year(year: i32) -> u16 {
72
72
/// ```
73
73
#[ inline( always) ]
74
74
pub fn weeks_in_year ( year : i32 ) -> u8 {
75
- let weekday = internals:: Date :: from_yo ( year, 1 ) . weekday ( ) ;
75
+ let weekday = internals:: Date :: from_yo_unchecked ( year, 1 ) . weekday ( ) ;
76
76
77
77
if ( weekday == Thursday ) || ( weekday == Wednesday && is_leap_year ( year) ) {
78
78
53
@@ -126,7 +126,7 @@ impl Date {
126
126
assert_value_in_range ! ( month in 1 => 12 ) ;
127
127
assert_value_in_range ! ( day in 1 => days_in_year_month( year, month) , given year, month) ;
128
128
129
- internals:: Date :: from_ymd ( year, month, day)
129
+ internals:: Date :: from_ymd_unchecked ( year, month, day)
130
130
}
131
131
132
132
/// Attempt to create a `Date` from the year, month, and day.
@@ -148,7 +148,7 @@ impl Date {
148
148
ensure_value_in_range ! ( month in 1 => 12 ) ;
149
149
ensure_value_in_range ! ( day in 1 => days_in_year_month( year, month) , given year, month) ;
150
150
151
- Ok ( internals:: Date :: from_ymd ( year, month, day) )
151
+ Ok ( internals:: Date :: from_ymd_unchecked ( year, month, day) )
152
152
}
153
153
154
154
/// Create a `Date` from the year and ordinal day number.
@@ -222,7 +222,7 @@ impl Date {
222
222
#[ cfg_attr( doc, doc( cfg( feature = "panicking-api" ) ) ) ]
223
223
pub fn from_iso_ywd ( year : i32 , week : u8 , weekday : Weekday ) -> Self {
224
224
assert_value_in_range ! ( week in 1 => weeks_in_year( year) , given year) ;
225
- internals:: Date :: from_iso_ywd ( year, week, weekday)
225
+ internals:: Date :: from_iso_ywd_unchecked ( year, week, weekday)
226
226
}
227
227
228
228
/// Attempt to create a `Date` from the ISO year, week, and weekday.
@@ -247,7 +247,7 @@ impl Date {
247
247
weekday : Weekday ,
248
248
) -> Result < Self , ComponentRangeError > {
249
249
ensure_value_in_range ! ( week in 1 => weeks_in_year( year) , given year) ;
250
- Ok ( internals:: Date :: from_iso_ywd ( year, week, weekday) )
250
+ Ok ( internals:: Date :: from_iso_ywd_unchecked ( year, week, weekday) )
251
251
}
252
252
253
253
/// Create a `Date` representing the current date.
@@ -687,7 +687,7 @@ impl Date {
687
687
688
688
// TODO Seek out a formal proof that this always results in a valid value.
689
689
#[ allow( clippy:: cast_possible_truncation, clippy:: cast_sign_loss) ]
690
- internals:: Date :: from_ymd ( year as i32 , month as u8 , day as u8 )
690
+ internals:: Date :: from_ymd_unchecked ( year as i32 , month as u8 , day as u8 )
691
691
}
692
692
}
693
693
@@ -977,7 +977,7 @@ impl Date {
977
977
/// Monday-based week numbering.
978
978
#[ inline( always) ]
979
979
fn adjustment ( year : i32 ) -> i16 {
980
- match internals:: Date :: from_yo ( year, 1 ) . weekday ( ) {
980
+ match internals:: Date :: from_yo_unchecked ( year, 1 ) . weekday ( ) {
981
981
Monday => 7 ,
982
982
Tuesday => 1 ,
983
983
Wednesday => 2 ,
@@ -990,14 +990,14 @@ impl Date {
990
990
991
991
// Verification for all components is done at parse time.
992
992
match items {
993
- items ! ( year, month, day) => Ok ( internals:: Date :: from_ymd ( year, month. get ( ) , day. get ( ) ) ) ,
994
- items ! ( year, ordinal_day) => Ok ( internals:: Date :: from_yo ( year, ordinal_day. get ( ) ) ) ,
995
- items ! ( week_based_year, iso_week, weekday) => Ok ( internals:: Date :: from_iso_ywd (
993
+ items ! ( year, month, day) => Ok ( internals:: Date :: from_ymd_unchecked ( year, month. get ( ) , day. get ( ) ) ) ,
994
+ items ! ( year, ordinal_day) => Ok ( internals:: Date :: from_yo_unchecked ( year, ordinal_day. get ( ) ) ) ,
995
+ items ! ( week_based_year, iso_week, weekday) => Ok ( internals:: Date :: from_iso_ywd_unchecked (
996
996
week_based_year,
997
997
iso_week. get ( ) ,
998
998
weekday,
999
999
) ) ,
1000
- items ! ( year, sunday_week, weekday) => Ok ( internals:: Date :: from_yo (
1000
+ items ! ( year, sunday_week, weekday) => Ok ( internals:: Date :: from_yo_unchecked (
1001
1001
year,
1002
1002
#[ allow( clippy:: cast_sign_loss) ]
1003
1003
{
@@ -1006,7 +1006,7 @@ impl Date {
1006
1006
+ 1 ) as u16
1007
1007
} ,
1008
1008
) ) ,
1009
- items ! ( year, monday_week, weekday) => Ok ( internals:: Date :: from_yo (
1009
+ items ! ( year, monday_week, weekday) => Ok ( internals:: Date :: from_yo_unchecked (
1010
1010
year,
1011
1011
#[ allow( clippy:: cast_sign_loss) ]
1012
1012
{
0 commit comments