@@ -69,15 +69,15 @@ macro_rules! make_any_calendar {
6969 type Year = $crate:: types:: YearInfo ;
7070 type DateCompatibilityError = $crate:: error:: MismatchedCalendarError ;
7171
72- fn from_codes2 (
72+ fn new_date (
7373 & self ,
7474 year: $crate:: types:: YearInput ,
7575 month: $crate:: types:: Month ,
7676 day: u8 ,
77- ) -> Result <Self :: DateInner , $crate:: error:: DateFromCodesError > {
77+ ) -> Result <Self :: DateInner , $crate:: error:: DateNewError > {
7878 Ok ( match self {
7979 $(
80- & Self :: $variant( ref c) => $any_date_ident:: $variant( c. from_codes2 ( year, month, day) ?) ,
80+ & Self :: $variant( ref c) => $any_date_ident:: $variant( c. new_date ( year, month, day) ?) ,
8181 ) +
8282 } )
8383 }
@@ -856,7 +856,7 @@ impl<C: IntoAnyCalendar> Date<C> {
856856#[ cfg( test) ]
857857mod tests {
858858 use super :: * ;
859- use crate :: error:: DateFromCodesError ;
859+ use crate :: error:: DateNewError ;
860860 use crate :: types:: { Month , YearInput } ;
861861 use crate :: Ref ;
862862
@@ -871,9 +871,9 @@ mod tests {
871871 let input = if let Some ( ( era, _) ) = era {
872872 YearInput :: EraYear ( era, year)
873873 } else {
874- YearInput :: Extended ( year)
874+ year. into ( )
875875 } ;
876- let date = Date :: try_from_codes ( input, month, day, calendar) . unwrap_or_else ( |e| {
876+ let date = Date :: try_new ( input, month, day, calendar) . unwrap_or_else ( |e| {
877877 panic ! (
878878 "Failed to construct date for {} with {era:?}, {year}, {month:?}, {day}: {e:?}" ,
879879 calendar. debug_name( ) ,
@@ -923,14 +923,14 @@ mod tests {
923923 year : i32 ,
924924 month : Month ,
925925 day : u8 ,
926- error : DateFromCodesError ,
926+ error : DateNewError ,
927927 ) {
928928 let input = if let Some ( ( era, _) ) = era {
929929 YearInput :: EraYear ( era, year)
930930 } else {
931- YearInput :: Extended ( year)
931+ year. into ( )
932932 } ;
933- let date = Date :: try_from_codes ( input, month, day, calendar) ;
933+ let date = Date :: try_new ( input, month, day, calendar) ;
934934 assert_eq ! (
935935 date,
936936 Err ( error) ,
@@ -952,7 +952,7 @@ mod tests {
952952 100 ,
953953 Month :: new ( 13 ) ,
954954 1 ,
955- DateFromCodesError :: MonthNotInCalendar ,
955+ DateNewError :: MonthNotInCalendar ,
956956 ) ;
957957 }
958958
@@ -971,7 +971,7 @@ mod tests {
971971 100 ,
972972 Month :: new ( 14 ) ,
973973 1 ,
974- DateFromCodesError :: MonthNotInCalendar ,
974+ DateNewError :: MonthNotInCalendar ,
975975 ) ;
976976 }
977977
@@ -984,7 +984,7 @@ mod tests {
984984 single_test_roundtrip ( ethiopian, None , -100 , Month :: new ( 3 ) , 1 ) ;
985985 single_test_roundtrip ( ethiopian, Some ( ( "am" , Some ( 1 ) ) ) , 2000 , Month :: new ( 13 ) , 1 ) ;
986986 single_test_roundtrip ( ethiopian, Some ( ( "aa" , Some ( 0 ) ) ) , 5400 , Month :: new ( 3 ) , 1 ) ;
987- // Since #6910, the era range is not enforced in try_from_codes
987+ // Since #6910, the era range is not enforced in try_new
988988 /*
989989 single_test_error(
990990 ethiopian,
@@ -1019,7 +1019,7 @@ mod tests {
10191019 100 ,
10201020 Month :: new ( 14 ) ,
10211021 1 ,
1022- DateFromCodesError :: MonthNotInCalendar ,
1022+ DateNewError :: MonthNotInCalendar ,
10231023 ) ;
10241024 }
10251025
@@ -1049,7 +1049,7 @@ mod tests {
10491049 100 ,
10501050 Month :: new ( 14 ) ,
10511051 1 ,
1052- DateFromCodesError :: MonthNotInCalendar ,
1052+ DateNewError :: MonthNotInCalendar ,
10531053 ) ;
10541054 }
10551055
@@ -1061,7 +1061,7 @@ mod tests {
10611061 single_test_roundtrip ( gregorian, None , 2000 , Month :: new ( 3 ) , 1 ) ;
10621062 single_test_roundtrip ( gregorian, None , -100 , Month :: new ( 3 ) , 1 ) ;
10631063 single_test_roundtrip ( gregorian, Some ( ( "bce" , Some ( 0 ) ) ) , 100 , Month :: new ( 3 ) , 1 ) ;
1064- // Since #6910, the era range is not enforced in try_from_codes
1064+ // Since #6910, the era range is not enforced in try_new
10651065 /*
10661066 single_test_error(
10671067 gregorian,
@@ -1096,7 +1096,7 @@ mod tests {
10961096 100 ,
10971097 Month :: new ( 13 ) ,
10981098 1 ,
1099- DateFromCodesError :: MonthNotInCalendar ,
1099+ DateNewError :: MonthNotInCalendar ,
11001100 ) ;
11011101 }
11021102
@@ -1114,7 +1114,7 @@ mod tests {
11141114 100 ,
11151115 Month :: new ( 13 ) ,
11161116 1 ,
1117- DateFromCodesError :: MonthNotInCalendar ,
1117+ DateNewError :: MonthNotInCalendar ,
11181118 ) ;
11191119 }
11201120
@@ -1131,7 +1131,7 @@ mod tests {
11311131 4658 ,
11321132 Month :: new ( 13 ) ,
11331133 1 ,
1134- DateFromCodesError :: MonthNotInCalendar ,
1134+ DateNewError :: MonthNotInCalendar ,
11351135 ) ;
11361136 }
11371137
@@ -1148,7 +1148,7 @@ mod tests {
11481148 9393 ,
11491149 Month :: leap ( 0 ) ,
11501150 1 ,
1151- DateFromCodesError :: MonthNotInCalendar ,
1151+ DateNewError :: MonthNotInCalendar ,
11521152 ) ;
11531153 }
11541154
@@ -1164,7 +1164,7 @@ mod tests {
11641164 single_test_roundtrip ( japanese, None , -100 , Month :: new ( 3 ) , 1 ) ;
11651165 single_test_roundtrip ( japanese, None , 2024 , Month :: new ( 3 ) , 1 ) ;
11661166 single_test_roundtrip ( japanese, Some ( ( "bce" , Some ( 0 ) ) ) , 10 , Month :: new ( 3 ) , 1 ) ;
1167- // Since #6910, the era range is not enforced in try_from_codes
1167+ // Since #6910, the era range is not enforced in try_new
11681168 /*
11691169 single_test_error(
11701170 japanese,
@@ -1199,7 +1199,7 @@ mod tests {
11991199 2 ,
12001200 Month :: new ( 13 ) ,
12011201 1 ,
1202- DateFromCodesError :: MonthNotInCalendar ,
1202+ DateNewError :: MonthNotInCalendar ,
12031203 ) ;
12041204 }
12051205
@@ -1217,7 +1217,7 @@ mod tests {
12171217 100 ,
12181218 Month :: new ( 50 ) ,
12191219 1 ,
1220- DateFromCodesError :: MonthNotInCalendar ,
1220+ DateNewError :: MonthNotInCalendar ,
12211221 ) ;
12221222 }
12231223
@@ -1235,7 +1235,7 @@ mod tests {
12351235 100 ,
12361236 Month :: new ( 50 ) ,
12371237 1 ,
1238- DateFromCodesError :: MonthNotInCalendar ,
1238+ DateNewError :: MonthNotInCalendar ,
12391239 ) ;
12401240 }
12411241
@@ -1276,7 +1276,7 @@ mod tests {
12761276 100 ,
12771277 Month :: new ( 50 ) ,
12781278 1 ,
1279- DateFromCodesError :: MonthNotInCalendar ,
1279+ DateNewError :: MonthNotInCalendar ,
12801280 ) ;
12811281 }
12821282
@@ -1306,7 +1306,7 @@ mod tests {
13061306 100 ,
13071307 Month :: new ( 50 ) ,
13081308 1 ,
1309- DateFromCodesError :: MonthNotInCalendar ,
1309+ DateNewError :: MonthNotInCalendar ,
13101310 ) ;
13111311 }
13121312
@@ -1337,7 +1337,7 @@ mod tests {
13371337 100 ,
13381338 Month :: new ( 50 ) ,
13391339 1 ,
1340- DateFromCodesError :: MonthNotInCalendar ,
1340+ DateNewError :: MonthNotInCalendar ,
13411341 ) ;
13421342 }
13431343
@@ -1355,7 +1355,7 @@ mod tests {
13551355 100 ,
13561356 Month :: new ( 13 ) ,
13571357 1 ,
1358- DateFromCodesError :: MonthNotInCalendar ,
1358+ DateNewError :: MonthNotInCalendar ,
13591359 ) ;
13601360 }
13611361}
0 commit comments