@@ -10,6 +10,7 @@ use crate::MismatchedCalendarError;
1010use core:: marker:: PhantomData ;
1111use icu_calendar:: cal;
1212use icu_calendar:: preferences:: { CalendarAlgorithm , CalendarPreferences , HijriCalendarAlgorithm } ;
13+ use icu_calendar:: types:: Weekday ;
1314use icu_calendar:: { AnyCalendar , AnyCalendarKind , AsCalendar , Date , IntoAnyCalendar , Ref } ;
1415use icu_provider:: marker:: NeverMarker ;
1516use icu_provider:: prelude:: * ;
@@ -600,6 +601,11 @@ impl CalMarkers<ErasedPackedPatterns> for FullDataCalMarkers {
600601}
601602
602603/// A type that can be converted into a specific calendar system.
604+ ///
605+ /// You often want to set `Converted` to an ICU4X built-in type.
606+ ///
607+ /// If the type is not calendar-specific, such as a time or time zone, set `Converted`
608+ /// to the same type and return it in the implementation.
603609// This trait is implementable
604610pub trait ConvertCalendar {
605611 /// The converted type. This can be the same as the receiver type.
@@ -649,6 +655,14 @@ impl<C: IntoAnyCalendar, A: AsCalendar<Calendar = C>, Z: Copy> ConvertCalendar
649655 }
650656}
651657
658+ impl ConvertCalendar for UtcOffset {
659+ type Converted < ' a > = UtcOffset ;
660+ #[ inline]
661+ fn to_calendar < ' a > ( & self , _: & ' a AnyCalendar ) -> Self :: Converted < ' a > {
662+ * self
663+ }
664+ }
665+
652666impl < O : TimeZoneModel > ConvertCalendar for TimeZoneInfo < O > {
653667 type Converted < ' a > = TimeZoneInfo < O > ;
654668 #[ inline]
@@ -657,6 +671,14 @@ impl<O: TimeZoneModel> ConvertCalendar for TimeZoneInfo<O> {
657671 }
658672}
659673
674+ impl ConvertCalendar for Weekday {
675+ type Converted < ' a > = Weekday ;
676+ #[ inline]
677+ fn to_calendar < ' a > ( & self , _: & ' a AnyCalendar ) -> Self :: Converted < ' a > {
678+ * self
679+ }
680+ }
681+
660682/// An input that may be associated with a specific runtime calendar.
661683// This trait is implementable
662684pub trait InSameCalendar {
@@ -727,7 +749,16 @@ impl<O: TimeZoneModel> InSameCalendar for TimeZoneInfo<O> {
727749 }
728750}
729751
752+ impl InSameCalendar for Weekday {
753+ #[ inline]
754+ fn check_any_calendar_kind ( & self , _: AnyCalendarKind ) -> Result < ( ) , MismatchedCalendarError > {
755+ Ok ( ( ) )
756+ }
757+ }
758+
730759/// An input associated with a fixed, static calendar.
760+ ///
761+ /// Inputs that are not calendar-specific should blanket-impl this for all `C`.
731762// This trait is implementable
732763pub trait InFixedCalendar < C > { }
733764
@@ -745,3 +776,5 @@ impl<C, Z> InFixedCalendar<C> for ZonedTime<Z> {}
745776impl < C > InFixedCalendar < C > for UtcOffset { }
746777
747778impl < C , O : TimeZoneModel > InFixedCalendar < C > for TimeZoneInfo < O > { }
779+
780+ impl < C > InFixedCalendar < C > for Weekday { }
0 commit comments