@@ -203,6 +203,15 @@ pub trait Rules: Clone + core::fmt::Debug + crate::cal::scaffold::UnstableSealed
203203 Err ( EcmaReferenceYearError :: Unimplemented )
204204 }
205205
206+ /// The error that is returned by [`Self::check_date_compatibility`].
207+ ///
208+ /// Set this to [`core::convert::Infallible`] if the type is a singleton or
209+ /// the parameterization does not affect calendar semantics.
210+ type DateCompatibilityError : core:: fmt:: Debug ;
211+
212+ /// Checks whether two [`Rules`] values are equal for the purpose of [`Date`] interaction.
213+ fn check_date_compatibility ( & self , other : & Self ) -> Result < ( ) , Self :: DateCompatibilityError > ;
214+
206215 /// The debug name for the calendar defined by these [`Rules`].
207216 fn debug_name ( & self ) -> & ' static str {
208217 "EastAsianTraditional (custom)"
@@ -302,6 +311,12 @@ impl Rules for China {
302311 ecma_reference_year_common ( month, day, EastAsianCalendarKind :: Chinese )
303312 }
304313
314+ type DateCompatibilityError = core:: convert:: Infallible ;
315+
316+ fn check_date_compatibility ( & self , & Self : & Self ) -> Result < ( ) , Self :: DateCompatibilityError > {
317+ Ok ( ( ) )
318+ }
319+
305320 fn calendar_algorithm ( & self ) -> Option < CalendarAlgorithm > {
306321 Some ( CalendarAlgorithm :: Chinese )
307322 }
@@ -437,6 +452,12 @@ impl Rules for Korea {
437452 ecma_reference_year_common ( month, day, EastAsianCalendarKind :: Korean )
438453 }
439454
455+ type DateCompatibilityError = core:: convert:: Infallible ;
456+
457+ fn check_date_compatibility ( & self , & Self : & Self ) -> Result < ( ) , Self :: DateCompatibilityError > {
458+ Ok ( ( ) )
459+ }
460+
440461 fn calendar_algorithm ( & self ) -> Option < CalendarAlgorithm > {
441462 Some ( CalendarAlgorithm :: Dangi )
442463 }
@@ -459,7 +480,7 @@ impl Date<KoreanTraditional> {
459480 /// .expect("Failed to initialize Date instance.");
460481 ///
461482 /// assert_eq!(date.cyclic_year().related_iso, 2025);
462- /// assert_eq!(date.month().as_input (), Month::new(5));
483+ /// assert_eq!(date.month().to_input (), Month::new(5));
463484 /// assert_eq!(date.day_of_month().0, 25);
464485 /// ```
465486 pub fn try_new_korean_traditional (
@@ -669,7 +690,7 @@ impl<R: Rules> crate::cal::scaffold::UnstableSealed for EastAsianTraditional<R>
669690impl < R : Rules > Calendar for EastAsianTraditional < R > {
670691 type DateInner = ChineseDateInner < R > ;
671692 type Year = types:: CyclicYear ;
672- type DifferenceError = core :: convert :: Infallible ;
693+ type DateCompatibilityError = R :: DateCompatibilityError ;
673694
674695 fn from_codes (
675696 & self ,
@@ -740,8 +761,12 @@ impl<R: Rules> Calendar for EastAsianTraditional<R> {
740761 date1 : & Self :: DateInner ,
741762 date2 : & Self :: DateInner ,
742763 options : DateDifferenceOptions ,
743- ) -> Result < types:: DateDuration , Self :: DifferenceError > {
744- Ok ( date1. 0 . until ( & date2. 0 , self , options) )
764+ ) -> types:: DateDuration {
765+ date1. 0 . until ( & date2. 0 , self , options)
766+ }
767+
768+ fn check_date_compatibility ( & self , other : & Self ) -> Result < ( ) , Self :: DateCompatibilityError > {
769+ self . 0 . check_date_compatibility ( & other. 0 )
745770 }
746771
747772 /// Obtain a name for the calendar for debug printing
@@ -808,7 +833,7 @@ impl Date<ChineseTraditional> {
808833 /// .expect("Failed to initialize Date instance.");
809834 ///
810835 /// assert_eq!(date.cyclic_year().related_iso, 2025);
811- /// assert_eq!(date.month().as_input (), Month::new(5));
836+ /// assert_eq!(date.month().to_input (), Month::new(5));
812837 /// assert_eq!(date.day_of_month().0, 25);
813838 /// ```
814839 pub fn try_new_chinese_traditional (
@@ -1146,6 +1171,12 @@ impl<R: Rules> Rules for EastAsianTraditionalYears<R> {
11461171 fn year_containing_rd ( & self , rd : RataDie ) -> EastAsianTraditionalYear {
11471172 self . 1 . year_containing_rd ( rd)
11481173 }
1174+
1175+ type DateCompatibilityError = R :: DateCompatibilityError ;
1176+
1177+ fn check_date_compatibility ( & self , other : & Self ) -> Result < ( ) , Self :: DateCompatibilityError > {
1178+ self . 1 . check_date_compatibility ( & other. 1 )
1179+ }
11491180}
11501181
11511182#[ cfg( test) ]
@@ -1376,7 +1407,7 @@ mod test {
13761407
13771408 assert_eq ! ( chinese. cyclic_year( ) . related_iso, -2636 ) ;
13781409 assert_eq ! ( chinese. month( ) . ordinal, 1 ) ;
1379- assert_eq ! ( chinese. month( ) . as_input ( ) , Month :: new( 1 ) ) ;
1410+ assert_eq ! ( chinese. month( ) . to_input ( ) , Month :: new( 1 ) ) ;
13801411 assert_eq ! ( chinese. day_of_month( ) . 0 , 1 ) ;
13811412 assert_eq ! ( chinese. cyclic_year( ) . year, 1 ) ;
13821413 assert_eq ! ( chinese. cyclic_year( ) . related_iso, -2636 ) ;
@@ -1569,7 +1600,7 @@ mod test {
15691600 let iso = Date :: try_new_iso ( case. iso_year , case. iso_month , case. iso_day ) . unwrap ( ) ;
15701601 let chinese = iso. to_calendar ( ChineseTraditional :: new ( ) ) ;
15711602 assert_eq ! (
1572- chinese. month( ) . as_input ( ) ,
1603+ chinese. month( ) . to_input ( ) ,
15731604 case. month,
15741605 "Month codes did not match for test case: {case:?}"
15751606 ) ;
@@ -1732,7 +1763,7 @@ mod test {
17321763 } ;
17331764 let date = Date :: try_from_fields ( fields, options, cal) . unwrap ( ) ;
17341765 assert_eq ! (
1735- date. month( ) . as_input ( ) ,
1766+ date. month( ) . to_input ( ) ,
17361767 Month :: new( 1 ) ,
17371768 "Month was successfully constrained"
17381769 ) ;
0 commit comments