From 6ac2b2cd5b140c979215f3a24c04dbdcc6fb04c6 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 8 Apr 2024 15:47:46 -0700 Subject: [PATCH 1/5] Add rest of the islamic calendars --- components/calendar/src/any_calendar.rs | 68 +- components/calendar/src/islamic.rs | 594 +++++----- components/calendar/src/provider.rs | 11 +- components/calendar/src/provider/islamic.rs | 23 +- components/datetime/src/any/date.rs | 6 +- components/datetime/src/any/datetime.rs | 9 +- components/datetime/src/any/zoned_datetime.rs | 9 +- components/datetime/src/external_loaders.rs | 3 + components/datetime/src/neo.rs | 15 +- provider/baked/calendar/data/macros.rs | 15 + .../calendar_islamiccivilcache_v1.rs.data | 27 + .../calendar_islamictabularcache_v1.rs.data | 27 + .../calendar_islamicummalquracache_v1.rs.data | 27 + provider/datagen/src/registry.rs | 3 + .../src/transform/cldr/calendar/islamic.rs | 62 +- provider/datagen/tests/data/baked/macros.rs | 15 + .../calendar_islamiccivilcache_v1.rs.data | 27 + .../calendar_islamictabularcache_v1.rs.data | 27 + .../calendar_islamicummalquracache_v1.rs.data | 27 + provider/datagen/tests/data/baked/mod.rs | 6 + .../calendar/islamiccivilcache@1/und.json | 1005 +++++++++++++++++ .../calendar/islamictabularcache@1/und.json | 1005 +++++++++++++++++ .../calendar/islamicummalquracache@1/und.json | 1005 +++++++++++++++++ .../tests/data/postcard/fingerprints.csv | 3 + 24 files changed, 3733 insertions(+), 286 deletions(-) create mode 100644 provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data create mode 100644 provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data create mode 100644 provider/baked/calendar/data/macros/calendar_islamicummalquracache_v1.rs.data create mode 100644 provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data create mode 100644 provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data create mode 100644 provider/datagen/tests/data/baked/macros/calendar_islamicummalquracache_v1.rs.data create mode 100644 provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json create mode 100644 provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json create mode 100644 provider/datagen/tests/data/json/calendar/islamicummalquracache@1/und.json diff --git a/components/calendar/src/any_calendar.rs b/components/calendar/src/any_calendar.rs index ba82b46f677..e26cd498c5f 100644 --- a/components/calendar/src/any_calendar.rs +++ b/components/calendar/src/any_calendar.rs @@ -585,12 +585,14 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), + AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil::new()), AnyCalendarKind::IslamicObservational => { AnyCalendar::IslamicObservational(IslamicObservational::new()) } - AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), - AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura), + AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular::new()), + AnyCalendarKind::IslamicUmmAlQura => { + AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura::new()) + } AnyCalendarKind::Iso => AnyCalendar::Iso(Iso), AnyCalendarKind::Japanese => AnyCalendar::Japanese(Japanese::new()), AnyCalendarKind::JapaneseExtended => { @@ -627,12 +629,18 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), + AnyCalendarKind::IslamicCivil => { + AnyCalendar::IslamicCivil(IslamicCivil::try_new_with_any_provider(provider)?) + } AnyCalendarKind::IslamicObservational => AnyCalendar::IslamicObservational( IslamicObservational::try_new_with_any_provider(provider)?, ), - AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), - AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura), + AnyCalendarKind::IslamicTabular => { + AnyCalendar::IslamicTabular(IslamicTabular::try_new_with_any_provider(provider)?) + } + AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura( + IslamicUmmAlQura::try_new_with_any_provider(provider)?, + ), AnyCalendarKind::Iso => AnyCalendar::Iso(Iso), AnyCalendarKind::Japanese => { AnyCalendar::Japanese(Japanese::try_new_with_any_provider(provider)?) @@ -672,12 +680,18 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), + AnyCalendarKind::IslamicCivil => { + AnyCalendar::IslamicCivil(IslamicCivil::try_new_with_buffer_provider(provider)?) + } AnyCalendarKind::IslamicObservational => AnyCalendar::IslamicObservational( IslamicObservational::try_new_with_buffer_provider(provider)?, ), - AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), - AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura), + AnyCalendarKind::IslamicTabular => { + AnyCalendar::IslamicTabular(IslamicTabular::try_new_with_buffer_provider(provider)?) + } + AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura( + IslamicUmmAlQura::try_new_with_buffer_provider(provider)?, + ), AnyCalendarKind::Iso => AnyCalendar::Iso(Iso), AnyCalendarKind::Japanese => { AnyCalendar::Japanese(Japanese::try_new_with_buffer_provider(provider)?) @@ -697,7 +711,10 @@ impl AnyCalendar { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + ?Sized, { Ok(match kind { @@ -714,12 +731,18 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), + AnyCalendarKind::IslamicCivil => { + AnyCalendar::IslamicCivil(IslamicCivil::try_new_unstable(provider)?) + } AnyCalendarKind::IslamicObservational => { AnyCalendar::IslamicObservational(IslamicObservational::try_new_unstable(provider)?) } - AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), - AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura), + AnyCalendarKind::IslamicTabular => { + AnyCalendar::IslamicTabular(IslamicTabular::try_new_unstable(provider)?) + } + AnyCalendarKind::IslamicUmmAlQura => { + AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura::try_new_unstable(provider)?) + } AnyCalendarKind::Iso => AnyCalendar::Iso(Iso), AnyCalendarKind::Japanese => { AnyCalendar::Japanese(Japanese::try_new_unstable(provider)?) @@ -770,7 +793,10 @@ impl AnyCalendar { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + ?Sized, { let kind = AnyCalendarKind::from_data_locale_with_fallback(locale); @@ -1039,10 +1065,10 @@ impl AnyCalendarKind { AnyCalendarKind::Gregorian => Gregorian.debug_name(), AnyCalendarKind::Hebrew => Hebrew.debug_name(), AnyCalendarKind::Indian => Indian.debug_name(), - AnyCalendarKind::IslamicCivil => IslamicCivil.debug_name(), + AnyCalendarKind::IslamicCivil => IslamicCivil::DEBUG_NAME, AnyCalendarKind::IslamicObservational => IslamicObservational::DEBUG_NAME, - AnyCalendarKind::IslamicTabular => IslamicTabular.debug_name(), - AnyCalendarKind::IslamicUmmAlQura => IslamicUmmAlQura.debug_name(), + AnyCalendarKind::IslamicTabular => IslamicTabular::DEBUG_NAME, + AnyCalendarKind::IslamicUmmAlQura => IslamicUmmAlQura::DEBUG_NAME, AnyCalendarKind::Iso => Iso.debug_name(), AnyCalendarKind::Japanese => Japanese::DEBUG_NAME, AnyCalendarKind::JapaneseExtended => JapaneseExtended::DEBUG_NAME, @@ -1221,10 +1247,10 @@ impl IntoAnyCalendar for Indian { impl IntoAnyCalendar for IslamicCivil { fn to_any(self) -> AnyCalendar { - AnyCalendar::IslamicCivil(IslamicCivil) + AnyCalendar::IslamicCivil(self) } fn to_any_cloned(&self) -> AnyCalendar { - AnyCalendar::IslamicCivil(IslamicCivil) + AnyCalendar::IslamicCivil(self.clone()) } fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner { AnyDateInner::IslamicCivil(*d) @@ -1245,10 +1271,10 @@ impl IntoAnyCalendar for IslamicObservational { impl IntoAnyCalendar for IslamicTabular { fn to_any(self) -> AnyCalendar { - AnyCalendar::IslamicTabular(IslamicTabular) + AnyCalendar::IslamicTabular(self) } fn to_any_cloned(&self) -> AnyCalendar { - AnyCalendar::IslamicTabular(IslamicTabular) + AnyCalendar::IslamicTabular(self.clone()) } fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner { AnyDateInner::IslamicTabular(*d) @@ -1257,10 +1283,10 @@ impl IntoAnyCalendar for IslamicTabular { impl IntoAnyCalendar for IslamicUmmAlQura { fn to_any(self) -> AnyCalendar { - AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura) + AnyCalendar::IslamicUmmAlQura(self) } fn to_any_cloned(&self) -> AnyCalendar { - AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura) + AnyCalendar::IslamicUmmAlQura(self.clone()) } fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner { AnyDateInner::IslamicUmmAlQura(*d) diff --git a/components/calendar/src/islamic.rs b/components/calendar/src/islamic.rs index 0be68694b71..37b7e2ac4dc 100644 --- a/components/calendar/src/islamic.rs +++ b/components/calendar/src/islamic.rs @@ -39,13 +39,17 @@ use crate::calendar_arithmetic::PrecomputedDataSource; use crate::calendar_arithmetic::{ArithmeticDate, CalendarArithmetic}; use crate::provider::islamic::{ - IslamicCacheV1, IslamicObservationalCacheV1Marker, PackedIslamicYearInfo, + IslamicCacheV1, IslamicCivilCacheV1Marker, IslamicObservationalCacheV1Marker, + IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, PackedIslamicYearInfo, }; use crate::AnyCalendarKind; use crate::AsCalendar; use crate::Iso; use crate::{types, Calendar, CalendarError, Date, DateDuration, DateDurationUnit, DateTime, Time}; -use calendrical_calculations::islamic::{IslamicBasedMarker, ObservationalIslamicMarker}; +use calendrical_calculations::islamic::{ + CivilIslamicMarker, IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, + TabularIslamicMarker, +}; use calendrical_calculations::rata_die::RataDie; use core::marker::PhantomData; use icu_provider::prelude::*; @@ -76,9 +80,10 @@ pub struct IslamicObservational { /// /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. -#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] -#[non_exhaustive] // we'll be adding precompiled data to this -pub struct IslamicCivil; +#[derive(Clone, Debug, Default)] +pub struct IslamicCivil { + data: Option>, +} /// Umm al-Qura Hijri Calendar (Used in Saudi Arabia) /// @@ -90,9 +95,10 @@ pub struct IslamicCivil; /// /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. -#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] -#[non_exhaustive] // we'll be adding precompiled data to this -pub struct IslamicUmmAlQura; +#[derive(Clone, Debug, Default)] +pub struct IslamicUmmAlQura { + data: Option>, +} /// A Tabular version of the Arithmetical Islamic Calendar /// @@ -104,9 +110,10 @@ pub struct IslamicUmmAlQura; /// /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. -#[derive(Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] -#[non_exhaustive] // we'll be adding precompiled data to this -pub struct IslamicTabular; +#[derive(Clone, Debug, Default)] +pub struct IslamicTabular { + data: Option>, +} impl IslamicObservational { /// Creates a new [`IslamicObservational`] with some precomputed calendrical calculations. @@ -149,32 +156,122 @@ impl IslamicObservational { } impl IslamicCivil { - /// Construct a new [`IslamicCivil`] without any precomputed calendrical calculations. + /// Creates a new [`IslamicCivil`] with some precomputed calendrical calculations. /// - /// This is the only mode currently possible, but once precomputing is available (#3933) - /// there will be additional constructors that load from data providers. + /// ✨ *Enabled with the `compiled_data` Cargo feature.* + /// + /// [📚 Help choosing a constructor](icu_provider::constructors) + #[cfg(feature = "compiled_data")] + pub const fn new() -> Self { + Self { + data: Some(DataPayload::from_static_ref( + crate::provider::Baked::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1, + )), + } + } + + icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: CalendarError, + #[cfg(skip)] + functions: [ + new, + try_new_with_any_provider, + try_new_with_buffer_provider, + try_new_unstable, + Self, + ]); + + #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] + pub fn try_new_unstable + ?Sized>( + provider: &D, + ) -> Result { + Ok(Self { + data: Some(provider.load(Default::default())?.take_payload()?), + }) + } + + /// Construct a new [`IslamicCivil`] without any precomputed calendrical calculations. pub fn new_always_calculating() -> Self { - IslamicCivil + Self { data: None } } } impl IslamicUmmAlQura { - /// Construct a new [`IslamicUmmAlQura`] without any precomputed calendrical calculations. + /// Creates a new [`IslamicUmmAlQura`] with some precomputed calendrical calculations. /// - /// This is the only mode currently possible, but once precomputing is available (#3933) - /// there will be additional constructors that load from data providers. + /// ✨ *Enabled with the `compiled_data` Cargo feature.* + /// + /// [📚 Help choosing a constructor](icu_provider::constructors) + #[cfg(feature = "compiled_data")] + pub const fn new() -> Self { + Self { + data: Some(DataPayload::from_static_ref( + crate::provider::Baked::SINGLETON_CALENDAR_ISLAMICUMMALQURACACHE_V1, + )), + } + } + + icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: CalendarError, + #[cfg(skip)] + functions: [ + new, + try_new_with_any_provider, + try_new_with_buffer_provider, + try_new_unstable, + Self, + ]); + + #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] + pub fn try_new_unstable + ?Sized>( + provider: &D, + ) -> Result { + Ok(Self { + data: Some(provider.load(Default::default())?.take_payload()?), + }) + } + + /// Construct a new [`IslamicUmmAlQura`] without any precomputed calendrical calculations. pub fn new_always_calculating() -> Self { - IslamicUmmAlQura + Self { data: None } } } impl IslamicTabular { - /// Construct a new [`IslamicTabular`] without any precomputed calendrical calculations. + /// Creates a new [`IslamicTabular`] with some precomputed calendrical calculations. + /// + /// ✨ *Enabled with the `compiled_data` Cargo feature.* /// - /// This is the only mode currently possible, but once precomputing is available (#3933) - /// there will be additional constructors that load from data providers. + /// [📚 Help choosing a constructor](icu_provider::constructors) + #[cfg(feature = "compiled_data")] + pub const fn new() -> Self { + Self { + data: Some(DataPayload::from_static_ref( + crate::provider::Baked::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1, + )), + } + } + + icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: CalendarError, + #[cfg(skip)] + functions: [ + new, + try_new_with_any_provider, + try_new_with_buffer_provider, + try_new_unstable, + Self, + ]); + + #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] + pub fn try_new_unstable + ?Sized>( + provider: &D, + ) -> Result { + Ok(Self { + data: Some(provider.load(Default::default())?.take_payload()?), + }) + } + + /// Construct a new [`IslamicTabular`] without any precomputed calendrical calculations. pub fn new_always_calculating() -> Self { - IslamicTabular + Self { data: None } } } @@ -261,6 +358,7 @@ fn compute_month_day(info: IslamicYearInfo, mut possible_month: u8, day_of_year: } else { info.packed_data.last_day_of_month(possible_month - 1) }; + while day_of_year > last_day_of_month && possible_month <= 12 { possible_month += 1; last_day_of_prev_month = last_day_of_month; @@ -289,7 +387,10 @@ impl<'b, IB: IslamicBasedMarker> IslamicPrecomputedData<'b, IB> { let ny = cached.packed_data.ny::(year); let day_of_year = (fixed - ny) as u16 + 1; debug_assert!(day_of_year < 360); - let possible_month = u8::try_from(1 + (day_of_year / 29)).unwrap_or(1); // + 1 because 1-indexed + // We divide by 30, not 29, to account for the case where all months before this + // were length 30 (possible near the beginning of the year) + // We add +1 because months are 1-indexed + let possible_month = u8::try_from(1 + (day_of_year / 30)).unwrap_or(1); let (m, d) = compute_month_day(cached, possible_month, day_of_year); return (cached, year, m, d); }; @@ -552,29 +653,27 @@ impl> DateTime { pub struct IslamicUmmAlQuraDateInner(ArithmeticDate); impl CalendarArithmetic for IslamicUmmAlQura { - type YearInfo = (); + type YearInfo = IslamicYearInfo; - fn month_days(year: i32, month: u8, _data: ()) -> u8 { - calendrical_calculations::islamic::saudi_islamic_month_days(year, month) + fn month_days(_year: i32, month: u8, year_info: IslamicYearInfo) -> u8 { + year_info.packed_data.days_in_month(month) } - fn months_for_every_year(_year: i32, _data: ()) -> u8 { + fn months_for_every_year(_year: i32, _year_info: IslamicYearInfo) -> u8 { 12 } - fn days_in_provided_year(year: i32, _data: ()) -> u16 { - (1..=12) - .map(|month| IslamicUmmAlQura::month_days(year, month, ()) as u16) - .sum() + fn days_in_provided_year(_year: i32, year_info: IslamicYearInfo) -> u16 { + year_info.packed_data.days_in_year() } - // As an observational-lunar calendar, it does not have leap years. - fn is_leap_year(_year: i32, _data: ()) -> bool { + // As an true lunar calendar, it does not have leap years. + fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { false } - fn last_month_day_in_year(year: i32, _data: ()) -> (u8, u8) { - let days = Self::month_days(year, 12, ()); + fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { + let days = Self::month_days(year, 12, year_info); (12, days) } @@ -598,17 +697,38 @@ impl Calendar for IslamicUmmAlQura { return Err(CalendarError::UnknownEra(era.0, self.debug_name())); }; - ArithmeticDate::new_from_codes(self, year, month_code, day).map(IslamicUmmAlQuraDateInner) + let month = if let Some((ordinal, false)) = month_code.parsed() { + ordinal + } else { + return Err(CalendarError::UnknownMonthCode( + month_code.0, + self.debug_name(), + )); + }; + ArithmeticDate::new_from_ordinals_with_info( + year, + month, + day, + self.precomputed_data().load_or_compute_info(year), + ) + .map(IslamicUmmAlQuraDateInner) } fn date_from_iso(&self, iso: Date) -> Self::DateInner { let fixed_iso = Iso::fixed_from_iso(*iso.inner()); - Self::saudi_islamic_from_fixed(fixed_iso).inner + + let (year_info, y, m, d) = self + .precomputed_data() + .load_or_compute_info_for_iso(fixed_iso); + IslamicUmmAlQuraDateInner(ArithmeticDate::new_unchecked_with_info(y, m, d, year_info)) } fn date_to_iso(&self, date: &Self::DateInner) -> Date { - let fixed_islamic = Self::fixed_from_saudi_islamic(*date); - Iso::iso_from_fixed(fixed_islamic) + let fixed = + date.0 + .year_info + .rd_for::(date.0.year, date.0.month, date.0.day); + Iso::iso_from_fixed(fixed) } fn months_in_year(&self, date: &Self::DateInner) -> u8 { @@ -624,7 +744,7 @@ impl Calendar for IslamicUmmAlQura { } fn offset_date(&self, date: &mut Self::DateInner, offset: DateDuration) { - date.0.offset_date(offset, &()) + date.0.offset_date(offset, &self.precomputed_data()) } fn until( @@ -639,7 +759,7 @@ impl Calendar for IslamicUmmAlQura { } fn debug_name(&self) -> &'static str { - "Islamic (Umm al-Qura)" + Self::DEBUG_NAME } fn year(&self, date: &Self::DateInner) -> types::FormattableYear { @@ -647,7 +767,7 @@ impl Calendar for IslamicUmmAlQura { } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { - Self::is_leap_year(date.0.year, ()) + Self::is_leap_year(date.0.year, date.0.year_info) } fn month(&self, date: &Self::DateInner) -> types::FormattableMonth { @@ -665,7 +785,7 @@ impl Calendar for IslamicUmmAlQura { day_of_year: date.0.day_of_year(), days_in_year: date.0.days_in_year(), prev_year: Self::year_as_islamic(prev_year), - days_in_prev_year: Self::days_in_provided_year(prev_year, ()), + days_in_prev_year: date.0.year_info.days_in_prev_year(), next_year: Self::year_as_islamic(next_year), } } @@ -675,6 +795,22 @@ impl Calendar for IslamicUmmAlQura { } } +impl IslamicUmmAlQura { + fn precomputed_data(&self) -> IslamicPrecomputedData { + IslamicPrecomputedData::new(self.data.as_ref().map(|x| x.get())) + } + + fn year_as_islamic(year: i32) -> types::FormattableYear { + types::FormattableYear { + era: types::Era(tinystr!(16, "islamic")), + number: year, + cyclic: None, + related_iso: None, + } + } + pub(crate) const DEBUG_NAME: &'static str = "Islamic (Umm al-Qura)"; +} + impl> Date { /// Construct new Islamic Umm al-Qura Date. /// @@ -699,7 +835,11 @@ impl> Date { day: u8, calendar: A, ) -> Result, CalendarError> { - ArithmeticDate::new_from_ordinals(year, month, day) + let year_info = calendar + .as_calendar() + .precomputed_data() + .load_or_compute_info(year); + ArithmeticDate::new_from_ordinals_with_info(year, month, day, year_info) .map(IslamicUmmAlQuraDateInner) .map(|inner| Date::from_raw(inner, calendar)) } @@ -741,81 +881,35 @@ impl> DateTime { } } -impl IslamicUmmAlQura { - fn fixed_from_saudi_islamic(i_date: IslamicUmmAlQuraDateInner) -> RataDie { - calendrical_calculations::islamic::fixed_from_saudi_islamic( - i_date.0.year, - i_date.0.month, - i_date.0.day, - ) - } - - fn saudi_islamic_from_fixed(date: RataDie) -> Date { - let (y, m, d) = calendrical_calculations::islamic::saudi_islamic_from_fixed(date); - - debug_assert!(Date::try_new_ummalqura_date( - y, - m, - d, - IslamicUmmAlQura::new_always_calculating() - ) - .is_ok()); - Date::from_raw( - IslamicUmmAlQuraDateInner(ArithmeticDate::new_unchecked(y, m, d)), - IslamicUmmAlQura, - ) - } - - fn year_as_islamic(year: i32) -> types::FormattableYear { - types::FormattableYear { - era: types::Era(tinystr!(16, "islamic")), - number: year, - cyclic: None, - related_iso: None, - } - } -} - /// The inner date type used for representing [`Date`]s of [`IslamicCivil`]. See [`Date`] and [`IslamicCivil`] for more details. #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] pub struct IslamicCivilDateInner(ArithmeticDate); impl CalendarArithmetic for IslamicCivil { - type YearInfo = (); - - fn month_days(year: i32, month: u8, _data: ()) -> u8 { - match month { - 1 | 3 | 5 | 7 | 9 | 11 => 30, - 2 | 4 | 6 | 8 | 10 => 29, - 12 if Self::is_leap_year(year, ()) => 30, - 12 => 29, - _ => 0, - } + type YearInfo = IslamicYearInfo; + + fn month_days(_year: i32, month: u8, year_info: IslamicYearInfo) -> u8 { + year_info.packed_data.days_in_month(month) } - fn months_for_every_year(_year: i32, _data: ()) -> u8 { + fn months_for_every_year(_year: i32, _year_info: IslamicYearInfo) -> u8 { 12 } - fn days_in_provided_year(year: i32, _data: ()) -> u16 { - if Self::is_leap_year(year, ()) { - 355 - } else { - 354 - } + fn days_in_provided_year(_year: i32, year_info: IslamicYearInfo) -> u16 { + year_info.packed_data.days_in_year() } - fn is_leap_year(year: i32, _data: ()) -> bool { - (14 + 11 * year).rem_euclid(30) < 11 + // As an true lunar calendar, it does not have leap years. + fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { + false } - fn last_month_day_in_year(year: i32, _data: ()) -> (u8, u8) { - if Self::is_leap_year(year, ()) { - (12, 30) - } else { - (12, 29) - } + fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { + let days = Self::month_days(year, 12, year_info); + + (12, days) } } @@ -840,17 +934,38 @@ impl Calendar for IslamicCivil { return Err(CalendarError::UnknownEra(era.0, self.debug_name())); }; - ArithmeticDate::new_from_codes(self, year, month_code, day).map(IslamicCivilDateInner) + let month = if let Some((ordinal, false)) = month_code.parsed() { + ordinal + } else { + return Err(CalendarError::UnknownMonthCode( + month_code.0, + self.debug_name(), + )); + }; + ArithmeticDate::new_from_ordinals_with_info( + year, + month, + day, + self.precomputed_data().load_or_compute_info(year), + ) + .map(IslamicCivilDateInner) } fn date_from_iso(&self, iso: Date) -> Self::DateInner { let fixed_iso = Iso::fixed_from_iso(*iso.inner()); - Self::islamic_from_fixed(fixed_iso).inner + + let (year_info, y, m, d) = self + .precomputed_data() + .load_or_compute_info_for_iso(fixed_iso); + IslamicCivilDateInner(ArithmeticDate::new_unchecked_with_info(y, m, d, year_info)) } fn date_to_iso(&self, date: &Self::DateInner) -> Date { - let fixed_islamic = Self::fixed_from_islamic(*date); - Iso::iso_from_fixed(fixed_islamic) + let fixed = + date.0 + .year_info + .rd_for::(date.0.year, date.0.month, date.0.day); + Iso::iso_from_fixed(fixed) } fn months_in_year(&self, date: &Self::DateInner) -> u8 { @@ -870,7 +985,7 @@ impl Calendar for IslamicCivil { } fn offset_date(&self, date: &mut Self::DateInner, offset: DateDuration) { - date.0.offset_date(offset, &()) + date.0.offset_date(offset, &self.precomputed_data()) } fn until( @@ -885,7 +1000,7 @@ impl Calendar for IslamicCivil { } fn debug_name(&self) -> &'static str { - "Islamic (civil)" + Self::DEBUG_NAME } fn year(&self, date: &Self::DateInner) -> types::FormattableYear { @@ -893,7 +1008,7 @@ impl Calendar for IslamicCivil { } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { - Self::is_leap_year(date.0.year, ()) + Self::is_leap_year(date.0.year, date.0.year_info) } fn month(&self, date: &Self::DateInner) -> types::FormattableMonth { @@ -911,7 +1026,7 @@ impl Calendar for IslamicCivil { day_of_year: date.0.day_of_year(), days_in_year: date.0.days_in_year(), prev_year: Self::year_as_islamic(prev_year), - days_in_prev_year: Self::days_in_provided_year(prev_year, ()), + days_in_prev_year: date.0.year_info.days_in_prev_year(), next_year: Self::year_as_islamic(next_year), } } @@ -921,28 +1036,8 @@ impl Calendar for IslamicCivil { } impl IslamicCivil { - fn fixed_from_islamic(i_date: IslamicCivilDateInner) -> RataDie { - calendrical_calculations::islamic::fixed_from_islamic_civil( - i_date.0.year, - i_date.0.month, - i_date.0.day, - ) - } - - fn islamic_from_fixed(date: RataDie) -> Date { - let (y, m, d) = calendrical_calculations::islamic::islamic_civil_from_fixed(date); - - debug_assert!(Date::try_new_islamic_civil_date_with_calendar( - y, - m, - d, - IslamicCivil::new_always_calculating() - ) - .is_ok()); - Date::from_raw( - IslamicCivilDateInner(ArithmeticDate::new_unchecked(y, m, d)), - IslamicCivil, - ) + fn precomputed_data(&self) -> IslamicPrecomputedData { + IslamicPrecomputedData::new(self.data.as_ref().map(|x| x.get())) } fn year_as_islamic(year: i32) -> types::FormattableYear { @@ -953,6 +1048,7 @@ impl IslamicCivil { related_iso: None, } } + pub(crate) const DEBUG_NAME: &'static str = "Islamic (civil)"; } impl> Date { @@ -980,7 +1076,11 @@ impl> Date { day: u8, calendar: A, ) -> Result, CalendarError> { - ArithmeticDate::new_from_ordinals(year, month, day) + let year_info = calendar + .as_calendar() + .precomputed_data() + .load_or_compute_info(year); + ArithmeticDate::new_from_ordinals_with_info(year, month, day, year_info) .map(IslamicCivilDateInner) .map(|inner| Date::from_raw(inner, calendar)) } @@ -1030,40 +1130,29 @@ impl> DateTime { pub struct IslamicTabularDateInner(ArithmeticDate); impl CalendarArithmetic for IslamicTabular { - type YearInfo = (); - - fn month_days(year: i32, month: u8, _data: ()) -> u8 { - match month { - 1 | 3 | 5 | 7 | 9 | 11 => 30, - 2 | 4 | 6 | 8 | 10 => 29, - 12 if Self::is_leap_year(year, ()) => 30, - 12 => 29, - _ => 0, - } + type YearInfo = IslamicYearInfo; + + fn month_days(_year: i32, month: u8, year_info: IslamicYearInfo) -> u8 { + year_info.packed_data.days_in_month(month) } - fn months_for_every_year(_year: i32, _data: ()) -> u8 { + fn months_for_every_year(_year: i32, _year_info: IslamicYearInfo) -> u8 { 12 } - fn days_in_provided_year(year: i32, _data: ()) -> u16 { - if Self::is_leap_year(year, ()) { - 355 - } else { - 354 - } + fn days_in_provided_year(_year: i32, year_info: IslamicYearInfo) -> u16 { + year_info.packed_data.days_in_year() } - fn is_leap_year(year: i32, _data: ()) -> bool { - (14 + 11 * year).rem_euclid(30) < 11 + // As an true lunar calendar, it does not have leap years. + fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { + false } - fn last_month_day_in_year(year: i32, _data: ()) -> (u8, u8) { - if Self::is_leap_year(year, ()) { - (12, 30) - } else { - (12, 29) - } + fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { + let days = Self::month_days(year, 12, year_info); + + (12, days) } } @@ -1086,17 +1175,38 @@ impl Calendar for IslamicTabular { return Err(CalendarError::UnknownEra(era.0, self.debug_name())); }; - ArithmeticDate::new_from_codes(self, year, month_code, day).map(IslamicTabularDateInner) + let month = if let Some((ordinal, false)) = month_code.parsed() { + ordinal + } else { + return Err(CalendarError::UnknownMonthCode( + month_code.0, + self.debug_name(), + )); + }; + ArithmeticDate::new_from_ordinals_with_info( + year, + month, + day, + self.precomputed_data().load_or_compute_info(year), + ) + .map(IslamicTabularDateInner) } fn date_from_iso(&self, iso: Date) -> Self::DateInner { let fixed_iso = Iso::fixed_from_iso(*iso.inner()); - Self::islamic_from_fixed(fixed_iso).inner + + let (year_info, y, m, d) = self + .precomputed_data() + .load_or_compute_info_for_iso(fixed_iso); + IslamicTabularDateInner(ArithmeticDate::new_unchecked_with_info(y, m, d, year_info)) } fn date_to_iso(&self, date: &Self::DateInner) -> Date { - let fixed_islamic = Self::fixed_from_islamic(*date); - Iso::iso_from_fixed(fixed_islamic) + let fixed = + date.0 + .year_info + .rd_for::(date.0.year, date.0.month, date.0.day); + Iso::iso_from_fixed(fixed) } fn months_in_year(&self, date: &Self::DateInner) -> u8 { @@ -1116,7 +1226,7 @@ impl Calendar for IslamicTabular { } fn offset_date(&self, date: &mut Self::DateInner, offset: DateDuration) { - date.0.offset_date(offset, &()) + date.0.offset_date(offset, &self.precomputed_data()) } fn until( @@ -1131,7 +1241,7 @@ impl Calendar for IslamicTabular { } fn debug_name(&self) -> &'static str { - "Islamic (tabular)" + Self::DEBUG_NAME } fn year(&self, date: &Self::DateInner) -> types::FormattableYear { @@ -1139,7 +1249,7 @@ impl Calendar for IslamicTabular { } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { - Self::is_leap_year(date.0.year, ()) + Self::is_leap_year(date.0.year, date.0.year_info) } fn month(&self, date: &Self::DateInner) -> types::FormattableMonth { @@ -1157,7 +1267,7 @@ impl Calendar for IslamicTabular { day_of_year: date.0.day_of_year(), days_in_year: date.0.days_in_year(), prev_year: Self::year_as_islamic(prev_year), - days_in_prev_year: Self::days_in_provided_year(prev_year, ()), + days_in_prev_year: date.0.year_info.days_in_prev_year(), next_year: Self::year_as_islamic(next_year), } } @@ -1167,28 +1277,8 @@ impl Calendar for IslamicTabular { } impl IslamicTabular { - fn fixed_from_islamic(i_date: IslamicTabularDateInner) -> RataDie { - calendrical_calculations::islamic::fixed_from_islamic_tabular( - i_date.0.year, - i_date.0.month, - i_date.0.day, - ) - } - - fn islamic_from_fixed(date: RataDie) -> Date { - let (y, m, d) = calendrical_calculations::islamic::islamic_tabular_from_fixed(date); - - debug_assert!(Date::try_new_islamic_civil_date_with_calendar( - y, - m, - d, - IslamicCivil::new_always_calculating() - ) - .is_ok()); - Date::from_raw( - IslamicTabularDateInner(ArithmeticDate::new_unchecked(y, m, d)), - IslamicTabular, - ) + fn precomputed_data(&self) -> IslamicPrecomputedData { + IslamicPrecomputedData::new(self.data.as_ref().map(|x| x.get())) } fn year_as_islamic(year: i32) -> types::FormattableYear { @@ -1199,6 +1289,7 @@ impl IslamicTabular { related_iso: None, } } + pub(crate) const DEBUG_NAME: &'static str = "Islamic (tabular)"; } impl> Date { @@ -1226,7 +1317,11 @@ impl> Date { day: u8, calendar: A, ) -> Result, CalendarError> { - ArithmeticDate::new_from_ordinals(year, month, day) + let year_info = calendar + .as_calendar() + .precomputed_data() + .load_or_compute_info(year); + ArithmeticDate::new_from_ordinals_with_info(year, month, day, year_info) .map(IslamicTabularDateInner) .map(|inner| Date::from_raw(inner, calendar)) } @@ -1987,103 +2082,87 @@ mod test { #[test] fn test_fixed_from_islamic() { + let calendar = IslamicCivil::new(); + let calendar = Ref(&calendar); for (case, f_date) in ARITHMETIC_CASES.iter().zip(TEST_FIXED_DATE.iter()) { - let date = IslamicCivilDateInner(ArithmeticDate::new_unchecked( - case.year, case.month, case.day, - )); - assert_eq!( - IslamicCivil::fixed_from_islamic(date), - RataDie::new(*f_date), - "{case:?}" - ); + let date = Date::try_new_islamic_civil_date_with_calendar( + case.year, case.month, case.day, calendar, + ) + .unwrap(); + assert_eq!(date.to_fixed(), RataDie::new(*f_date), "{case:?}"); } } #[test] fn test_islamic_from_fixed() { + let calendar = IslamicCivil::new(); + let calendar = Ref(&calendar); for (case, f_date) in ARITHMETIC_CASES.iter().zip(TEST_FIXED_DATE.iter()) { let date = Date::try_new_islamic_civil_date_with_calendar( - case.year, - case.month, - case.day, - IslamicCivil::new_always_calculating(), + case.year, case.month, case.day, calendar, ) .unwrap(); - assert_eq!( - IslamicCivil::islamic_from_fixed(RataDie::new(*f_date)), - date, - "{case:?}" - ); + let iso = Iso::iso_from_fixed(RataDie::new(*f_date)); + + assert_eq!(iso.to_calendar(calendar).inner, date.inner, "{case:?}"); } } #[test] fn test_fixed_from_islamic_tbla() { + let calendar = IslamicTabular::new(); + let calendar = Ref(&calendar); for (case, f_date) in TABULAR_CASES.iter().zip(TEST_FIXED_DATE.iter()) { - let date = IslamicTabularDateInner(ArithmeticDate::new_unchecked( - case.year, case.month, case.day, - )); - assert_eq!( - IslamicTabular::fixed_from_islamic(date), - RataDie::new(*f_date), - "{case:?}" - ); + let date = Date::try_new_islamic_tabular_date_with_calendar( + case.year, case.month, case.day, calendar, + ) + .unwrap(); + assert_eq!(date.to_fixed(), RataDie::new(*f_date), "{case:?}"); } } #[test] fn test_islamic_tbla_from_fixed() { + let calendar = IslamicTabular::new(); + let calendar = Ref(&calendar); for (case, f_date) in TABULAR_CASES.iter().zip(TEST_FIXED_DATE.iter()) { let date = Date::try_new_islamic_tabular_date_with_calendar( - case.year, - case.month, - case.day, - IslamicTabular::new_always_calculating(), + case.year, case.month, case.day, calendar, ) .unwrap(); - assert_eq!( - IslamicTabular::islamic_from_fixed(RataDie::new(*f_date)), - date, - "{case:?}" - ); + let iso = Iso::iso_from_fixed(RataDie::new(*f_date)); + + assert_eq!(iso.to_calendar(calendar).inner, date.inner, "{case:?}"); } } #[test] fn test_saudi_islamic_from_fixed() { + let calendar = IslamicUmmAlQura::new(); + let calendar = Ref(&calendar); for (case, f_date) in UMMALQURA_DATE_EXPECTED .iter() .zip(TEST_FIXED_DATE_UMMALQURA.iter()) { - let date = Date::try_new_ummalqura_date( - case.year, - case.month, - case.day, - IslamicUmmAlQura::new_always_calculating(), - ) - .unwrap(); - assert_eq!( - IslamicUmmAlQura::saudi_islamic_from_fixed(RataDie::new(*f_date)), - date, - "{case:?}" - ); + let date = + Date::try_new_ummalqura_date(case.year, case.month, case.day, calendar).unwrap(); + let iso = Iso::iso_from_fixed(RataDie::new(*f_date)); + + assert_eq!(iso.to_calendar(calendar).inner, date.inner, "{case:?}"); } } #[test] fn test_fixed_from_saudi_islamic() { + let calendar = IslamicUmmAlQura::new(); + let calendar = Ref(&calendar); for (case, f_date) in UMMALQURA_DATE_EXPECTED .iter() .zip(TEST_FIXED_DATE_UMMALQURA.iter()) { - let date = IslamicUmmAlQuraDateInner(ArithmeticDate::new_unchecked( - case.year, case.month, case.day, - )); - assert_eq!( - IslamicUmmAlQura::fixed_from_saudi_islamic(date), - RataDie::new(*f_date), - "{case:?}" - ); + let date = + Date::try_new_ummalqura_date(case.year, case.month, case.day, calendar).unwrap(); + assert_eq!(date.to_fixed(), RataDie::new(*f_date), "{case:?}"); } } @@ -2120,17 +2199,24 @@ mod test { #[ignore] #[test] fn test_days_in_provided_year_ummalqura() { + let calendar = IslamicUmmAlQura::new(); + let calendar = Ref(&calendar); // -1245 1 1 = -214528 (R.D Date) // 1518 1 1 = 764588 (R.D Date) let sum_days_in_year: i64 = (START_YEAR..END_YEAR) - .map(|year| IslamicUmmAlQura::days_in_provided_year(year, ()) as i64) + .map(|year| { + IslamicUmmAlQura::days_in_provided_year( + year, + IslamicYearInfo::compute::(year), + ) as i64 + }) .sum(); - - let expected_number_of_days = IslamicUmmAlQura::fixed_from_saudi_islamic( - IslamicUmmAlQuraDateInner(ArithmeticDate::new_from_ordinals(END_YEAR, 1, 1).unwrap()), - ) - IslamicUmmAlQura::fixed_from_saudi_islamic( - IslamicUmmAlQuraDateInner(ArithmeticDate::new_from_ordinals(START_YEAR, 1, 1).unwrap()), - ); // The number of days between Umm al-Qura Islamic years -1245 and 1518 + let expected_number_of_days = Date::try_new_ummalqura_date(END_YEAR, 1, 1, calendar) + .unwrap() + .to_fixed() + - Date::try_new_ummalqura_date(START_YEAR, 1, 1, calendar) + .unwrap() + .to_fixed(); // The number of days between Umm al-Qura Islamic years -1245 and 1518 assert_eq!(sum_days_in_year, expected_number_of_days); } @@ -2139,7 +2225,7 @@ mod test { fn test_regression_3868() { // This date used to panic on creation let iso = Date::try_new_iso_date(2011, 4, 4).unwrap(); - let islamic = iso.to_calendar(IslamicUmmAlQura); + let islamic = iso.to_calendar(IslamicUmmAlQura::new()); // Data from https://www.ummulqura.org.sa/Index.aspx assert_eq!(islamic.day_of_month().0, 30); assert_eq!(islamic.month().ordinal, 4); diff --git a/components/calendar/src/provider.rs b/components/calendar/src/provider.rs index a9a7381b9db..16719d8de8b 100644 --- a/components/calendar/src/provider.rs +++ b/components/calendar/src/provider.rs @@ -18,7 +18,10 @@ pub mod chinese_based; pub mod islamic; pub use chinese_based::{ChineseCacheV1Marker, DangiCacheV1Marker}; -pub use islamic::IslamicObservationalCacheV1Marker; +pub use islamic::{ + IslamicCivilCacheV1Marker, IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, + IslamicUmmAlQuraCacheV1Marker, +}; use crate::types::IsoWeekday; use core::str::FromStr; @@ -47,7 +50,10 @@ const _: () = { icu_calendar_data::make_provider!(Baked); icu_calendar_data::impl_calendar_chinesecache_v1!(Baked); icu_calendar_data::impl_calendar_dangicache_v1!(Baked); + icu_calendar_data::impl_calendar_islamiccivilcache_v1!(Baked); icu_calendar_data::impl_calendar_islamicobservationalcache_v1!(Baked); + icu_calendar_data::impl_calendar_islamicummalquracache_v1!(Baked); + icu_calendar_data::impl_calendar_islamictabularcache_v1!(Baked); icu_calendar_data::impl_calendar_japanese_v1!(Baked); icu_calendar_data::impl_calendar_japanext_v1!(Baked); icu_calendar_data::impl_datetime_week_data_v1!(Baked); @@ -59,7 +65,10 @@ const _: () = { pub const KEYS: &[DataKey] = &[ ChineseCacheV1Marker::KEY, DangiCacheV1Marker::KEY, + IslamicCivilCacheV1Marker::KEY, IslamicObservationalCacheV1Marker::KEY, + IslamicUmmAlQuraCacheV1Marker::KEY, + IslamicTabularCacheV1Marker::KEY, JapaneseErasV1Marker::KEY, JapaneseExtendedErasV1Marker::KEY, WeekDataV2Marker::KEY, diff --git a/components/calendar/src/provider/islamic.rs b/components/calendar/src/provider/islamic.rs index 4d56ee57e85..2f74b1da97e 100644 --- a/components/calendar/src/provider/islamic.rs +++ b/components/calendar/src/provider/islamic.rs @@ -22,11 +22,24 @@ use zerovec::ZeroVec; /// Cached/precompiled data for a certain range of years for a chinese-based /// calendar. Avoids the need to perform lunar calendar arithmetic for most calendrical /// operations. -#[icu_provider::data_struct(marker( - IslamicObservationalCacheV1Marker, - "calendar/islamicobservationalcache@1", - singleton -))] +#[icu_provider::data_struct( + marker( + IslamicObservationalCacheV1Marker, + "calendar/islamicobservationalcache@1", + singleton + ), + marker(IslamicCivilCacheV1Marker, "calendar/islamiccivilcache@1", singleton), + marker( + IslamicUmmAlQuraCacheV1Marker, + "calendar/islamicummalquracache@1", + singleton + ), + marker( + IslamicTabularCacheV1Marker, + "calendar/islamictabularcache@1", + singleton + ) +)] #[derive(Debug, PartialEq, Clone, Default)] #[cfg_attr( feature = "datagen", diff --git a/components/datetime/src/any/date.rs b/components/datetime/src/any/date.rs index 080e89f1c87..b703965e93e 100644 --- a/components/datetime/src/any/date.rs +++ b/components/datetime/src/any/date.rs @@ -9,7 +9,8 @@ use crate::{input::DateInput, DateTimeError, FormattedDateTime}; use alloc::string::String; use icu_calendar::any_calendar::AnyCalendar; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, + IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, }; use icu_decimal::provider::DecimalSymbolsV1Marker; @@ -187,7 +188,10 @@ impl DateFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/any/datetime.rs b/components/datetime/src/any/datetime.rs index 56871f0611f..286a60416bc 100644 --- a/components/datetime/src/any/datetime.rs +++ b/components/datetime/src/any/datetime.rs @@ -9,7 +9,8 @@ use crate::{input::DateTimeInput, DateTimeError, FormattedDateTime}; use alloc::string::String; use icu_calendar::any_calendar::AnyCalendar; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, + IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, }; use icu_decimal::provider::DecimalSymbolsV1Marker; @@ -241,7 +242,10 @@ impl DateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider @@ -389,7 +393,10 @@ impl DateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/any/zoned_datetime.rs b/components/datetime/src/any/zoned_datetime.rs index 00639a83972..e239c23d238 100644 --- a/components/datetime/src/any/zoned_datetime.rs +++ b/components/datetime/src/any/zoned_datetime.rs @@ -14,7 +14,8 @@ use crate::time_zone::TimeZoneFormatterOptions; use crate::{DateTimeError, FormattedZonedDateTime}; use icu_calendar::any_calendar::{AnyCalendar, AnyCalendarKind}; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, + IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, }; use icu_calendar::{DateTime, Time}; @@ -257,7 +258,10 @@ impl ZonedDateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider @@ -412,7 +416,10 @@ impl ZonedDateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/external_loaders.rs b/components/datetime/src/external_loaders.rs index 8678b67b212..736ced15d75 100644 --- a/components/datetime/src/external_loaders.rs +++ b/components/datetime/src/external_loaders.rs @@ -207,7 +207,10 @@ where + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + ?Sized, { #[inline] diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index 07ca8bd8bea..5cd8796c1d6 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -21,7 +21,8 @@ use crate::Error; use core::fmt; use core::marker::PhantomData; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, + IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV2Marker, }; use icu_calendar::AnyCalendar; @@ -510,7 +511,10 @@ impl NeoDateFormatter { // AnyCalendar constructor keys + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider // FixedDecimalFormatter keys @@ -1471,7 +1475,10 @@ impl NeoDateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider @@ -1644,7 +1651,10 @@ impl NeoDateTimeFormatter { // AnyCalendar constructor keys + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider // FixedDecimalFormatter keys @@ -1772,7 +1782,10 @@ impl NeoDateTimeFormatter { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + + DataProvider + + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/provider/baked/calendar/data/macros.rs b/provider/baked/calendar/data/macros.rs index 6f8a9fb0e9b..6651504d6e7 100644 --- a/provider/baked/calendar/data/macros.rs +++ b/provider/baked/calendar/data/macros.rs @@ -36,11 +36,26 @@ mod calendar_dangicache_v1; #[doc(inline)] pub use __impl_calendar_dangicache_v1 as impl_calendar_dangicache_v1; #[macro_use] +#[path = "macros/calendar_islamiccivilcache_v1.rs.data"] +mod calendar_islamiccivilcache_v1; +#[doc(inline)] +pub use __impl_calendar_islamiccivilcache_v1 as impl_calendar_islamiccivilcache_v1; +#[macro_use] #[path = "macros/calendar_islamicobservationalcache_v1.rs.data"] mod calendar_islamicobservationalcache_v1; #[doc(inline)] pub use __impl_calendar_islamicobservationalcache_v1 as impl_calendar_islamicobservationalcache_v1; #[macro_use] +#[path = "macros/calendar_islamictabularcache_v1.rs.data"] +mod calendar_islamictabularcache_v1; +#[doc(inline)] +pub use __impl_calendar_islamictabularcache_v1 as impl_calendar_islamictabularcache_v1; +#[macro_use] +#[path = "macros/calendar_islamicummalquracache_v1.rs.data"] +mod calendar_islamicummalquracache_v1; +#[doc(inline)] +pub use __impl_calendar_islamicummalquracache_v1 as impl_calendar_islamicummalquracache_v1; +#[macro_use] #[path = "macros/calendar_japanese_v1.rs.data"] mod calendar_japanese_v1; #[doc(inline)] diff --git a/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data b/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data new file mode 100644 index 00000000000..b459e2fd073 --- /dev/null +++ b/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamiccivilcache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data b/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data new file mode 100644 index 00000000000..f732a88b438 --- /dev/null +++ b/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamictabularcache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/baked/calendar/data/macros/calendar_islamicummalquracache_v1.rs.data b/provider/baked/calendar/data/macros/calendar_islamicummalquracache_v1.rs.data new file mode 100644 index 00000000000..a8d72710791 --- /dev/null +++ b/provider/baked/calendar/data/macros/calendar_islamicummalquracache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamicummalquracache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICUMMALQURACACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b".5\xAD:\xAA\x05\xA5;I\x0B\x95\nK5\x9B:Z\x05U;R\x0F\xA4\x0EJ\x0E\x95\n-5\xAD6j\x0BT\x07I\x07\x956+=Z\t\xBA2\xB95\xB4\x0Bd\x0B\xAA\nV\n\xB64m9\xEC2\xE96\xB2\x0ET\r\xAA\x0C:\t\xB62u5j;T\x0B%\x0BK:\x1B5[:\xB62\xB56\xA9\x0E\x92\x0E%\rM:\xAD4[9Z;\xD2\x06\xA5\x0EJ\x0E\x96\x0C6\x05u:t\x05i;R\x07\xA9\x06U5\xAD:\xEC\x04\xEA:\xD4\x05\xC9=R\r\xA5\n\xD54u9\xF4\x04\xE9:\xD2\x06\xA5\x06+5W2\xB7Tv9j\x05e=J\r\x96\x0C.9]2\xDD4\xD6:\xAA\x06\x956'5W:\xAE4m9j\x03e;\xC9\x06\x936+5g9\xD62\xD55\xD2\r\xA4\x0BI\x0B\x95\n-5\xAD5j;\xE4\x06\xC9\r\x92\r\xA6\nV\t\xAE2m5j3U;\xAA\nM9\x9D4]9\xBA2\xB55\xAA\x05U=\x9A\n.9\x9E2]5\xDA:\xD4\x06\xA5\x06K=\x96\nN\x05\xAE:\xAC\x05\xA9;\x92\r%\x0BK6\xABJ\x0E\x95\n-5\xAD:l\x03Y7\xD2\x06\x95\x06-5[:\xBA4\xBA9\xB4\x03i;R\x0B\xA6\n\xB64m9\xEC\x02\xD96\xB2\x0ET\r*\rV\n\xB64m9j\rT\x0B)\x0B\x93:+5W:65\xB5:\xAA\x06\x93>&\rM\n\xAD4[9\xDA<\xD4\x06\xA9\x0ER\x0E\xAA\x0CV\t\xB5:t\x05q;d\x07\xC9\x06U5\xAD2m5\xEA:\xE4\x05\xD1\rR\r\xA5\nU9u2\xED4\xE9:\xD2\x06\xA5\x06K9W4\xB78\xB62u5j=J\r\x96\x0C.9^2\xDD4\xDA:\xD2\x06\xA55K5\x97:\xAE4m9j\x03e;R\x07\xA5\x06K5\xAB:Z5\xD56\xD2\r\xA4\x0BJ\x0B\x95\nM5\xAD9j\x03\xD55\xCA\x05\x95=*\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICUMMALQURACACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/datagen/src/registry.rs b/provider/datagen/src/registry.rs index 03adf862b94..cf180e3e5f9 100644 --- a/provider/datagen/src/registry.rs +++ b/provider/datagen/src/registry.rs @@ -141,8 +141,11 @@ registry!( icu_calendar::provider::ChineseCacheV1Marker = "calendar/chinesecache@1", icu_calendar::provider::DangiCacheV1Marker = "calendar/dangicache@1", icu_calendar::provider::JapaneseErasV1Marker = "calendar/japanese@1", + icu_calendar::provider::IslamicCivilCacheV1Marker = "calendar/islamiccivilcache@1", icu_calendar::provider::IslamicObservationalCacheV1Marker = "calendar/islamicobservationalcache@1", + icu_calendar::provider::IslamicUmmAlQuraCacheV1Marker = "calendar/islamicummalquracache@1", + icu_calendar::provider::IslamicTabularCacheV1Marker = "calendar/islamictabularcache@1", icu_calendar::provider::JapaneseExtendedErasV1Marker = "calendar/japanext@1", icu_calendar::provider::WeekDataV1Marker = "datetime/week_data@1", icu_calendar::provider::WeekDataV2Marker = "datetime/week_data@2", diff --git a/provider/datagen/src/transform/cldr/calendar/islamic.rs b/provider/datagen/src/transform/cldr/calendar/islamic.rs index 2cb825490aa..0bd4e4985c4 100644 --- a/provider/datagen/src/transform/cldr/calendar/islamic.rs +++ b/provider/datagen/src/transform/cldr/calendar/islamic.rs @@ -2,7 +2,10 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). -use calendrical_calculations::islamic::{IslamicBasedMarker, ObservationalIslamicMarker}; +use calendrical_calculations::islamic::{ + CivilIslamicMarker, IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, + TabularIslamicMarker, +}; use calendrical_calculations::iso; use icu_calendar::provider::islamic::*; use icu_provider::datagen::IterableDataProvider; @@ -36,3 +39,60 @@ impl IterableDataProvider for crate::DatagenP Ok(vec![Default::default()]) } } + +impl DataProvider for crate::DatagenProvider { + fn load(&self, req: DataRequest) -> Result, DataError> { + self.check_req::(req)?; + let cache = load::(); + Ok(DataResponse { + metadata: DataResponseMetadata::default(), + payload: Some(DataPayload::from_owned(cache)), + }) + } +} + +impl IterableDataProvider for crate::DatagenProvider { + fn supported_locales(&self) -> Result, DataError> { + Ok(vec![Default::default()]) + } +} + +impl DataProvider for crate::DatagenProvider { + fn load( + &self, + req: DataRequest, + ) -> Result, DataError> { + self.check_req::(req)?; + let cache = load::(); + Ok(DataResponse { + metadata: DataResponseMetadata::default(), + payload: Some(DataPayload::from_owned(cache)), + }) + } +} + +impl IterableDataProvider for crate::DatagenProvider { + fn supported_locales(&self) -> Result, DataError> { + Ok(vec![Default::default()]) + } +} + +impl DataProvider for crate::DatagenProvider { + fn load( + &self, + req: DataRequest, + ) -> Result, DataError> { + self.check_req::(req)?; + let cache = load::(); + Ok(DataResponse { + metadata: DataResponseMetadata::default(), + payload: Some(DataPayload::from_owned(cache)), + }) + } +} + +impl IterableDataProvider for crate::DatagenProvider { + fn supported_locales(&self) -> Result, DataError> { + Ok(vec![Default::default()]) + } +} diff --git a/provider/datagen/tests/data/baked/macros.rs b/provider/datagen/tests/data/baked/macros.rs index 54d0106556e..9670bcefd84 100644 --- a/provider/datagen/tests/data/baked/macros.rs +++ b/provider/datagen/tests/data/baked/macros.rs @@ -36,11 +36,26 @@ mod calendar_dangicache_v1; #[doc(inline)] pub use __impl_calendar_dangicache_v1 as impl_calendar_dangicache_v1; #[macro_use] +#[path = "macros/calendar_islamiccivilcache_v1.rs.data"] +mod calendar_islamiccivilcache_v1; +#[doc(inline)] +pub use __impl_calendar_islamiccivilcache_v1 as impl_calendar_islamiccivilcache_v1; +#[macro_use] #[path = "macros/calendar_islamicobservationalcache_v1.rs.data"] mod calendar_islamicobservationalcache_v1; #[doc(inline)] pub use __impl_calendar_islamicobservationalcache_v1 as impl_calendar_islamicobservationalcache_v1; #[macro_use] +#[path = "macros/calendar_islamictabularcache_v1.rs.data"] +mod calendar_islamictabularcache_v1; +#[doc(inline)] +pub use __impl_calendar_islamictabularcache_v1 as impl_calendar_islamictabularcache_v1; +#[macro_use] +#[path = "macros/calendar_islamicummalquracache_v1.rs.data"] +mod calendar_islamicummalquracache_v1; +#[doc(inline)] +pub use __impl_calendar_islamicummalquracache_v1 as impl_calendar_islamicummalquracache_v1; +#[macro_use] #[path = "macros/calendar_japanese_v1.rs.data"] mod calendar_japanese_v1; #[doc(inline)] diff --git a/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data b/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data new file mode 100644 index 00000000000..b459e2fd073 --- /dev/null +++ b/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamiccivilcache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data b/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data new file mode 100644 index 00000000000..f732a88b438 --- /dev/null +++ b/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamictabularcache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/datagen/tests/data/baked/macros/calendar_islamicummalquracache_v1.rs.data b/provider/datagen/tests/data/baked/macros/calendar_islamicummalquracache_v1.rs.data new file mode 100644 index 00000000000..a8d72710791 --- /dev/null +++ b/provider/datagen/tests/data/baked/macros/calendar_islamicummalquracache_v1.rs.data @@ -0,0 +1,27 @@ +// @generated +/// Implement `DataProvider` on the given struct using the data +/// hardcoded in this file. This allows the struct to be used with +/// `icu`'s `_unstable` constructors. +#[doc(hidden)] +#[macro_export] +macro_rules! __impl_calendar_islamicummalquracache_v1 { + ($ provider : ty) => { + #[clippy::msrv = "1.67"] + const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; + #[clippy::msrv = "1.67"] + impl $provider { + #[doc(hidden)] + pub const SINGLETON_CALENDAR_ISLAMICUMMALQURACACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b".5\xAD:\xAA\x05\xA5;I\x0B\x95\nK5\x9B:Z\x05U;R\x0F\xA4\x0EJ\x0E\x95\n-5\xAD6j\x0BT\x07I\x07\x956+=Z\t\xBA2\xB95\xB4\x0Bd\x0B\xAA\nV\n\xB64m9\xEC2\xE96\xB2\x0ET\r\xAA\x0C:\t\xB62u5j;T\x0B%\x0BK:\x1B5[:\xB62\xB56\xA9\x0E\x92\x0E%\rM:\xAD4[9Z;\xD2\x06\xA5\x0EJ\x0E\x96\x0C6\x05u:t\x05i;R\x07\xA9\x06U5\xAD:\xEC\x04\xEA:\xD4\x05\xC9=R\r\xA5\n\xD54u9\xF4\x04\xE9:\xD2\x06\xA5\x06+5W2\xB7Tv9j\x05e=J\r\x96\x0C.9]2\xDD4\xD6:\xAA\x06\x956'5W:\xAE4m9j\x03e;\xC9\x06\x936+5g9\xD62\xD55\xD2\r\xA4\x0BI\x0B\x95\n-5\xAD5j;\xE4\x06\xC9\r\x92\r\xA6\nV\t\xAE2m5j3U;\xAA\nM9\x9D4]9\xBA2\xB55\xAA\x05U=\x9A\n.9\x9E2]5\xDA:\xD4\x06\xA5\x06K=\x96\nN\x05\xAE:\xAC\x05\xA9;\x92\r%\x0BK6\xABJ\x0E\x95\n-5\xAD:l\x03Y7\xD2\x06\x95\x06-5[:\xBA4\xBA9\xB4\x03i;R\x0B\xA6\n\xB64m9\xEC\x02\xD96\xB2\x0ET\r*\rV\n\xB64m9j\rT\x0B)\x0B\x93:+5W:65\xB5:\xAA\x06\x93>&\rM\n\xAD4[9\xDA<\xD4\x06\xA9\x0ER\x0E\xAA\x0CV\t\xB5:t\x05q;d\x07\xC9\x06U5\xAD2m5\xEA:\xE4\x05\xD1\rR\r\xA5\nU9u2\xED4\xE9:\xD2\x06\xA5\x06K9W4\xB78\xB62u5j=J\r\x96\x0C.9^2\xDD4\xDA:\xD2\x06\xA55K5\x97:\xAE4m9j\x03e;R\x07\xA5\x06K5\xAB:Z5\xD56\xD2\r\xA4\x0BJ\x0B\x95\nM5\xAD9j\x03\xD55\xCA\x05\x95=*\x05") } }; + } + #[clippy::msrv = "1.67"] + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + if req.locale.is_empty() { + Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICUMMALQURACACHE_V1)), metadata: Default::default() }) + } else { + Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) + } + } + } + }; +} diff --git a/provider/datagen/tests/data/baked/mod.rs b/provider/datagen/tests/data/baked/mod.rs index 4ca721b3614..b20f2fade81 100644 --- a/provider/datagen/tests/data/baked/mod.rs +++ b/provider/datagen/tests/data/baked/mod.rs @@ -5,7 +5,10 @@ macro_rules! impl_data_provider { make_provider!($provider); impl_calendar_chinesecache_v1!($provider); impl_calendar_dangicache_v1!($provider); + impl_calendar_islamiccivilcache_v1!($provider); impl_calendar_islamicobservationalcache_v1!($provider); + impl_calendar_islamictabularcache_v1!($provider); + impl_calendar_islamicummalquracache_v1!($provider); impl_calendar_japanese_v1!($provider); impl_calendar_japanext_v1!($provider); impl_collator_data_v1!($provider); @@ -297,7 +300,10 @@ macro_rules! impl_any_provider { match key.hashed() { h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), + h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), + h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), + h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), diff --git a/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json b/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json new file mode 100644 index 00000000000..08bd4ba979c --- /dev/null +++ b/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json @@ -0,0 +1,1005 @@ +{ + "first_extended_year": 1317, + "data": [ + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ] + ] +} diff --git a/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json b/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json new file mode 100644 index 00000000000..08bd4ba979c --- /dev/null +++ b/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json @@ -0,0 +1,1005 @@ +{ + "first_extended_year": 1317, + "data": [ + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 13 + ], + [ + 85, + 5 + ], + [ + 85, + 5 + ], + [ + 85, + 61 + ], + [ + 85, + 5 + ] + ] +} diff --git a/provider/datagen/tests/data/json/calendar/islamicummalquracache@1/und.json b/provider/datagen/tests/data/json/calendar/islamicummalquracache@1/und.json new file mode 100644 index 00000000000..f9c63e38ec6 --- /dev/null +++ b/provider/datagen/tests/data/json/calendar/islamicummalquracache@1/und.json @@ -0,0 +1,1005 @@ +{ + "first_extended_year": 1317, + "data": [ + [ + 46, + 53 + ], + [ + 173, + 58 + ], + [ + 170, + 5 + ], + [ + 165, + 59 + ], + [ + 73, + 11 + ], + [ + 149, + 10 + ], + [ + 75, + 53 + ], + [ + 155, + 58 + ], + [ + 90, + 5 + ], + [ + 85, + 59 + ], + [ + 82, + 15 + ], + [ + 164, + 14 + ], + [ + 74, + 14 + ], + [ + 149, + 10 + ], + [ + 45, + 53 + ], + [ + 173, + 54 + ], + [ + 106, + 11 + ], + [ + 84, + 7 + ], + [ + 73, + 7 + ], + [ + 149, + 54 + ], + [ + 43, + 61 + ], + [ + 90, + 9 + ], + [ + 186, + 50 + ], + [ + 185, + 53 + ], + [ + 180, + 11 + ], + [ + 100, + 11 + ], + [ + 170, + 10 + ], + [ + 86, + 10 + ], + [ + 182, + 52 + ], + [ + 109, + 57 + ], + [ + 236, + 50 + ], + [ + 233, + 54 + ], + [ + 178, + 14 + ], + [ + 84, + 13 + ], + [ + 170, + 12 + ], + [ + 58, + 9 + ], + [ + 182, + 50 + ], + [ + 117, + 53 + ], + [ + 106, + 59 + ], + [ + 84, + 11 + ], + [ + 37, + 11 + ], + [ + 75, + 58 + ], + [ + 27, + 53 + ], + [ + 91, + 58 + ], + [ + 182, + 50 + ], + [ + 181, + 54 + ], + [ + 169, + 14 + ], + [ + 146, + 14 + ], + [ + 37, + 13 + ], + [ + 77, + 58 + ], + [ + 173, + 52 + ], + [ + 91, + 57 + ], + [ + 90, + 59 + ], + [ + 210, + 6 + ], + [ + 165, + 14 + ], + [ + 74, + 14 + ], + [ + 150, + 12 + ], + [ + 54, + 5 + ], + [ + 117, + 58 + ], + [ + 116, + 5 + ], + [ + 105, + 59 + ], + [ + 82, + 7 + ], + [ + 169, + 6 + ], + [ + 85, + 53 + ], + [ + 173, + 58 + ], + [ + 236, + 4 + ], + [ + 234, + 58 + ], + [ + 212, + 5 + ], + [ + 201, + 61 + ], + [ + 82, + 13 + ], + [ + 165, + 10 + ], + [ + 213, + 52 + ], + [ + 117, + 57 + ], + [ + 244, + 4 + ], + [ + 233, + 58 + ], + [ + 210, + 6 + ], + [ + 165, + 6 + ], + [ + 43, + 53 + ], + [ + 87, + 50 + ], + [ + 183, + 84 + ], + [ + 118, + 57 + ], + [ + 106, + 5 + ], + [ + 101, + 61 + ], + [ + 74, + 13 + ], + [ + 150, + 12 + ], + [ + 46, + 57 + ], + [ + 93, + 50 + ], + [ + 221, + 52 + ], + [ + 214, + 58 + ], + [ + 170, + 6 + ], + [ + 149, + 54 + ], + [ + 39, + 53 + ], + [ + 87, + 58 + ], + [ + 174, + 52 + ], + [ + 109, + 57 + ], + [ + 106, + 3 + ], + [ + 101, + 59 + ], + [ + 201, + 6 + ], + [ + 147, + 54 + ], + [ + 43, + 53 + ], + [ + 103, + 57 + ], + [ + 214, + 50 + ], + [ + 213, + 53 + ], + [ + 210, + 13 + ], + [ + 164, + 11 + ], + [ + 73, + 11 + ], + [ + 149, + 10 + ], + [ + 45, + 53 + ], + [ + 173, + 53 + ], + [ + 106, + 59 + ], + [ + 228, + 6 + ], + [ + 201, + 13 + ], + [ + 146, + 13 + ], + [ + 166, + 10 + ], + [ + 86, + 9 + ], + [ + 174, + 50 + ], + [ + 109, + 53 + ], + [ + 106, + 51 + ], + [ + 85, + 59 + ], + [ + 170, + 10 + ], + [ + 77, + 57 + ], + [ + 157, + 52 + ], + [ + 93, + 57 + ], + [ + 186, + 50 + ], + [ + 181, + 53 + ], + [ + 170, + 5 + ], + [ + 85, + 61 + ], + [ + 154, + 10 + ], + [ + 46, + 57 + ], + [ + 158, + 50 + ], + [ + 93, + 53 + ], + [ + 218, + 58 + ], + [ + 212, + 6 + ], + [ + 165, + 6 + ], + [ + 75, + 61 + ], + [ + 150, + 10 + ], + [ + 78, + 5 + ], + [ + 174, + 58 + ], + [ + 172, + 5 + ], + [ + 169, + 59 + ], + [ + 146, + 13 + ], + [ + 37, + 11 + ], + [ + 75, + 54 + ], + [ + 171, + 60 + ], + [ + 90, + 5 + ], + [ + 85, + 59 + ], + [ + 210, + 6 + ], + [ + 165, + 62 + ], + [ + 74, + 14 + ], + [ + 149, + 10 + ], + [ + 45, + 53 + ], + [ + 173, + 58 + ], + [ + 108, + 3 + ], + [ + 89, + 55 + ], + [ + 210, + 6 + ], + [ + 149, + 6 + ], + [ + 45, + 53 + ], + [ + 91, + 58 + ], + [ + 186, + 52 + ], + [ + 186, + 57 + ], + [ + 180, + 3 + ], + [ + 105, + 59 + ], + [ + 82, + 11 + ], + [ + 166, + 10 + ], + [ + 182, + 52 + ], + [ + 109, + 57 + ], + [ + 236, + 2 + ], + [ + 217, + 54 + ], + [ + 178, + 14 + ], + [ + 84, + 13 + ], + [ + 42, + 13 + ], + [ + 86, + 10 + ], + [ + 182, + 52 + ], + [ + 109, + 57 + ], + [ + 106, + 13 + ], + [ + 84, + 11 + ], + [ + 41, + 11 + ], + [ + 147, + 58 + ], + [ + 43, + 53 + ], + [ + 87, + 58 + ], + [ + 54, + 53 + ], + [ + 181, + 58 + ], + [ + 170, + 6 + ], + [ + 147, + 62 + ], + [ + 38, + 13 + ], + [ + 77, + 10 + ], + [ + 173, + 52 + ], + [ + 91, + 57 + ], + [ + 218, + 60 + ], + [ + 212, + 6 + ], + [ + 169, + 14 + ], + [ + 82, + 14 + ], + [ + 170, + 12 + ], + [ + 86, + 9 + ], + [ + 181, + 58 + ], + [ + 116, + 5 + ], + [ + 113, + 59 + ], + [ + 100, + 7 + ], + [ + 201, + 6 + ], + [ + 85, + 53 + ], + [ + 173, + 50 + ], + [ + 109, + 53 + ], + [ + 234, + 58 + ], + [ + 228, + 5 + ], + [ + 209, + 13 + ], + [ + 82, + 13 + ], + [ + 165, + 10 + ], + [ + 85, + 57 + ], + [ + 117, + 50 + ], + [ + 237, + 52 + ], + [ + 233, + 58 + ], + [ + 210, + 6 + ], + [ + 165, + 6 + ], + [ + 75, + 57 + ], + [ + 87, + 52 + ], + [ + 183, + 56 + ], + [ + 182, + 50 + ], + [ + 117, + 53 + ], + [ + 106, + 61 + ], + [ + 74, + 13 + ], + [ + 150, + 12 + ], + [ + 46, + 57 + ], + [ + 94, + 50 + ], + [ + 221, + 52 + ], + [ + 218, + 58 + ], + [ + 210, + 6 + ], + [ + 165, + 53 + ], + [ + 75, + 53 + ], + [ + 151, + 58 + ], + [ + 174, + 52 + ], + [ + 109, + 57 + ], + [ + 106, + 3 + ], + [ + 101, + 59 + ], + [ + 82, + 7 + ], + [ + 165, + 6 + ], + [ + 75, + 53 + ], + [ + 171, + 58 + ], + [ + 90, + 53 + ], + [ + 213, + 54 + ], + [ + 210, + 13 + ], + [ + 164, + 11 + ], + [ + 74, + 11 + ], + [ + 149, + 10 + ], + [ + 77, + 53 + ], + [ + 173, + 57 + ], + [ + 106, + 3 + ], + [ + 213, + 53 + ], + [ + 202, + 5 + ], + [ + 149, + 61 + ], + [ + 42, + 5 + ] + ] +} diff --git a/provider/datagen/tests/data/postcard/fingerprints.csv b/provider/datagen/tests/data/postcard/fingerprints.csv index 110d9507af4..b791b775e21 100644 --- a/provider/datagen/tests/data/postcard/fingerprints.csv +++ b/provider/datagen/tests/data/postcard/fingerprints.csv @@ -1,6 +1,9 @@ calendar/chinesecache@1, und, 754B, c116ab2a7479b26d calendar/dangicache@1, und, 754B, d7565838cc8c6aa6 +calendar/islamiccivilcache@1, und, 504B, b558648c456bc311 calendar/islamicobservationalcache@1, und, 504B, 31c8968bfd922ede +calendar/islamictabularcache@1, und, 504B, b558648c456bc311 +calendar/islamicummalquracache@1, und, 504B, ef6ac9ff14fd3f3 calendar/japanese@1, und, 111B, b31e52deaf52706f calendar/japanext@1, und, 5216B, 6c20e216c8cd6e41 collator/data@1, ar, 8267B, fce742b37324adbe From c651a3459db3623fb738b6b26602fd0ec02e9c24 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 11 Apr 2024 16:32:20 -0700 Subject: [PATCH 2/5] undo civil/tabular --- components/calendar/src/any_calendar.rs | 36 +- components/calendar/src/islamic.rs | 299 ++--- components/calendar/src/provider.rs | 9 +- components/calendar/src/provider/islamic.rs | 6 - components/datetime/src/any/date.rs | 8 +- components/datetime/src/any/datetime.rs | 10 +- components/datetime/src/any/zoned_datetime.rs | 10 +- components/datetime/src/external_loaders.rs | 2 - components/datetime/src/neo.rs | 14 +- provider/baked/calendar/data/macros.rs | 10 - .../calendar_islamiccivilcache_v1.rs.data | 27 - .../calendar_islamictabularcache_v1.rs.data | 27 - provider/datagen/src/registry.rs | 2 - .../src/transform/cldr/calendar/islamic.rs | 40 +- provider/datagen/tests/data/baked/macros.rs | 10 - .../calendar_islamiccivilcache_v1.rs.data | 27 - .../calendar_islamictabularcache_v1.rs.data | 27 - provider/datagen/tests/data/baked/mod.rs | 4 - .../calendar/islamiccivilcache@1/und.json | 1005 ----------------- .../calendar/islamictabularcache@1/und.json | 1005 ----------------- .../tests/data/postcard/fingerprints.csv | 2 - 21 files changed, 145 insertions(+), 2435 deletions(-) delete mode 100644 provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data delete mode 100644 provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data delete mode 100644 provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data delete mode 100644 provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data delete mode 100644 provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json delete mode 100644 provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json diff --git a/components/calendar/src/any_calendar.rs b/components/calendar/src/any_calendar.rs index e26cd498c5f..ac310253ca8 100644 --- a/components/calendar/src/any_calendar.rs +++ b/components/calendar/src/any_calendar.rs @@ -585,11 +585,11 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil::new()), + AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), AnyCalendarKind::IslamicObservational => { AnyCalendar::IslamicObservational(IslamicObservational::new()) } - AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular::new()), + AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), AnyCalendarKind::IslamicUmmAlQura => { AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura::new()) } @@ -629,15 +629,11 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => { - AnyCalendar::IslamicCivil(IslamicCivil::try_new_with_any_provider(provider)?) - } + AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), AnyCalendarKind::IslamicObservational => AnyCalendar::IslamicObservational( IslamicObservational::try_new_with_any_provider(provider)?, ), - AnyCalendarKind::IslamicTabular => { - AnyCalendar::IslamicTabular(IslamicTabular::try_new_with_any_provider(provider)?) - } + AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura( IslamicUmmAlQura::try_new_with_any_provider(provider)?, ), @@ -680,15 +676,11 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => { - AnyCalendar::IslamicCivil(IslamicCivil::try_new_with_buffer_provider(provider)?) - } + AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), AnyCalendarKind::IslamicObservational => AnyCalendar::IslamicObservational( IslamicObservational::try_new_with_buffer_provider(provider)?, ), - AnyCalendarKind::IslamicTabular => { - AnyCalendar::IslamicTabular(IslamicTabular::try_new_with_buffer_provider(provider)?) - } + AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), AnyCalendarKind::IslamicUmmAlQura => AnyCalendar::IslamicUmmAlQura( IslamicUmmAlQura::try_new_with_buffer_provider(provider)?, ), @@ -711,9 +703,7 @@ impl AnyCalendar { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider - + DataProvider + DataProvider + ?Sized, { @@ -731,15 +721,11 @@ impl AnyCalendar { AnyCalendarKind::Gregorian => AnyCalendar::Gregorian(Gregorian), AnyCalendarKind::Hebrew => AnyCalendar::Hebrew(Hebrew), AnyCalendarKind::Indian => AnyCalendar::Indian(Indian), - AnyCalendarKind::IslamicCivil => { - AnyCalendar::IslamicCivil(IslamicCivil::try_new_unstable(provider)?) - } + AnyCalendarKind::IslamicCivil => AnyCalendar::IslamicCivil(IslamicCivil), AnyCalendarKind::IslamicObservational => { AnyCalendar::IslamicObservational(IslamicObservational::try_new_unstable(provider)?) } - AnyCalendarKind::IslamicTabular => { - AnyCalendar::IslamicTabular(IslamicTabular::try_new_unstable(provider)?) - } + AnyCalendarKind::IslamicTabular => AnyCalendar::IslamicTabular(IslamicTabular), AnyCalendarKind::IslamicUmmAlQura => { AnyCalendar::IslamicUmmAlQura(IslamicUmmAlQura::try_new_unstable(provider)?) } @@ -793,10 +779,8 @@ impl AnyCalendar { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + ?Sized, { let kind = AnyCalendarKind::from_data_locale_with_fallback(locale); @@ -1065,9 +1049,9 @@ impl AnyCalendarKind { AnyCalendarKind::Gregorian => Gregorian.debug_name(), AnyCalendarKind::Hebrew => Hebrew.debug_name(), AnyCalendarKind::Indian => Indian.debug_name(), - AnyCalendarKind::IslamicCivil => IslamicCivil::DEBUG_NAME, + AnyCalendarKind::IslamicCivil => IslamicCivil.debug_name(), AnyCalendarKind::IslamicObservational => IslamicObservational::DEBUG_NAME, - AnyCalendarKind::IslamicTabular => IslamicTabular::DEBUG_NAME, + AnyCalendarKind::IslamicTabular => IslamicTabular.debug_name(), AnyCalendarKind::IslamicUmmAlQura => IslamicUmmAlQura::DEBUG_NAME, AnyCalendarKind::Iso => Iso.debug_name(), AnyCalendarKind::Japanese => Japanese::DEBUG_NAME, diff --git a/components/calendar/src/islamic.rs b/components/calendar/src/islamic.rs index 37b7e2ac4dc..19c822f26ca 100644 --- a/components/calendar/src/islamic.rs +++ b/components/calendar/src/islamic.rs @@ -39,16 +39,15 @@ use crate::calendar_arithmetic::PrecomputedDataSource; use crate::calendar_arithmetic::{ArithmeticDate, CalendarArithmetic}; use crate::provider::islamic::{ - IslamicCacheV1, IslamicCivilCacheV1Marker, IslamicObservationalCacheV1Marker, - IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, PackedIslamicYearInfo, + IslamicCacheV1, IslamicObservationalCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, + PackedIslamicYearInfo, }; use crate::AnyCalendarKind; use crate::AsCalendar; use crate::Iso; use crate::{types, Calendar, CalendarError, Date, DateDuration, DateDurationUnit, DateTime, Time}; use calendrical_calculations::islamic::{ - CivilIslamicMarker, IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, - TabularIslamicMarker, + IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, }; use calendrical_calculations::rata_die::RataDie; use core::marker::PhantomData; @@ -81,9 +80,7 @@ pub struct IslamicObservational { /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. #[derive(Clone, Debug, Default)] -pub struct IslamicCivil { - data: Option>, -} +pub struct IslamicCivil; /// Umm al-Qura Hijri Calendar (Used in Saudi Arabia) /// @@ -111,9 +108,7 @@ pub struct IslamicUmmAlQura { /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. #[derive(Clone, Debug, Default)] -pub struct IslamicTabular { - data: Option>, -} +pub struct IslamicTabular; impl IslamicObservational { /// Creates a new [`IslamicObservational`] with some precomputed calendrical calculations. @@ -156,42 +151,15 @@ impl IslamicObservational { } impl IslamicCivil { - /// Creates a new [`IslamicCivil`] with some precomputed calendrical calculations. - /// - /// ✨ *Enabled with the `compiled_data` Cargo feature.* - /// - /// [📚 Help choosing a constructor](icu_provider::constructors) - #[cfg(feature = "compiled_data")] - pub const fn new() -> Self { - Self { - data: Some(DataPayload::from_static_ref( - crate::provider::Baked::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1, - )), - } - } - - icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: CalendarError, - #[cfg(skip)] - functions: [ - new, - try_new_with_any_provider, - try_new_with_buffer_provider, - try_new_unstable, - Self, - ]); - - #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] - pub fn try_new_unstable + ?Sized>( - provider: &D, - ) -> Result { - Ok(Self { - data: Some(provider.load(Default::default())?.take_payload()?), - }) + /// Construct a new [`IslamicCivil`] + pub fn new() -> Self { + Self } - /// Construct a new [`IslamicCivil`] without any precomputed calendrical calculations. + /// Construct a new [`IslamicCivil`] (deprecated: we will not add precomputation to this calendar) + #[deprecated = "Precomputation not needed for this calendar"] pub fn new_always_calculating() -> Self { - Self { data: None } + Self } } @@ -236,42 +204,15 @@ impl IslamicUmmAlQura { } impl IslamicTabular { - /// Creates a new [`IslamicTabular`] with some precomputed calendrical calculations. - /// - /// ✨ *Enabled with the `compiled_data` Cargo feature.* - /// - /// [📚 Help choosing a constructor](icu_provider::constructors) - #[cfg(feature = "compiled_data")] - pub const fn new() -> Self { - Self { - data: Some(DataPayload::from_static_ref( - crate::provider::Baked::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1, - )), - } - } - - icu_provider::gen_any_buffer_data_constructors!(locale: skip, options: skip, error: CalendarError, - #[cfg(skip)] - functions: [ - new, - try_new_with_any_provider, - try_new_with_buffer_provider, - try_new_unstable, - Self, - ]); - - #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::new)] - pub fn try_new_unstable + ?Sized>( - provider: &D, - ) -> Result { - Ok(Self { - data: Some(provider.load(Default::default())?.take_payload()?), - }) + /// Construct a new [`IslamicTabular`] + pub fn new() -> Self { + Self } - /// Construct a new [`IslamicTabular`] without any precomputed calendrical calculations. + /// Construct a new [`IslamicTabular`] (deprecated: we will not add precomputation to this calendar) + #[deprecated = "Precomputation not needed for this calendar"] pub fn new_always_calculating() -> Self { - Self { data: None } + Self } } @@ -887,29 +828,40 @@ impl> DateTime { pub struct IslamicCivilDateInner(ArithmeticDate); impl CalendarArithmetic for IslamicCivil { - type YearInfo = IslamicYearInfo; - - fn month_days(_year: i32, month: u8, year_info: IslamicYearInfo) -> u8 { - year_info.packed_data.days_in_month(month) + type YearInfo = (); + + fn month_days(year: i32, month: u8, _data: ()) -> u8 { + match month { + 1 | 3 | 5 | 7 | 9 | 11 => 30, + 2 | 4 | 6 | 8 | 10 => 29, + 12 if Self::is_leap_year(year, ()) => 30, + 12 => 29, + _ => 0, + } } - fn months_for_every_year(_year: i32, _year_info: IslamicYearInfo) -> u8 { + fn months_for_every_year(_year: i32, _data: ()) -> u8 { 12 } - fn days_in_provided_year(_year: i32, year_info: IslamicYearInfo) -> u16 { - year_info.packed_data.days_in_year() + fn days_in_provided_year(year: i32, _data: ()) -> u16 { + if Self::is_leap_year(year, ()) { + 355 + } else { + 354 + } } - // As an true lunar calendar, it does not have leap years. - fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { - false + fn is_leap_year(year: i32, _data: ()) -> bool { + (14 + 11 * year).rem_euclid(30) < 11 } - fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { - let days = Self::month_days(year, 12, year_info); - - (12, days) + fn last_month_day_in_year(year: i32, _data: ()) -> (u8, u8) { + if Self::is_leap_year(year, ()) { + (12, 30) + } else { + (12, 29) + } } } @@ -934,38 +886,17 @@ impl Calendar for IslamicCivil { return Err(CalendarError::UnknownEra(era.0, self.debug_name())); }; - let month = if let Some((ordinal, false)) = month_code.parsed() { - ordinal - } else { - return Err(CalendarError::UnknownMonthCode( - month_code.0, - self.debug_name(), - )); - }; - ArithmeticDate::new_from_ordinals_with_info( - year, - month, - day, - self.precomputed_data().load_or_compute_info(year), - ) - .map(IslamicCivilDateInner) + ArithmeticDate::new_from_codes(self, year, month_code, day).map(IslamicCivilDateInner) } fn date_from_iso(&self, iso: Date) -> Self::DateInner { let fixed_iso = Iso::fixed_from_iso(*iso.inner()); - - let (year_info, y, m, d) = self - .precomputed_data() - .load_or_compute_info_for_iso(fixed_iso); - IslamicCivilDateInner(ArithmeticDate::new_unchecked_with_info(y, m, d, year_info)) + Self::islamic_from_fixed(fixed_iso).inner } fn date_to_iso(&self, date: &Self::DateInner) -> Date { - let fixed = - date.0 - .year_info - .rd_for::(date.0.year, date.0.month, date.0.day); - Iso::iso_from_fixed(fixed) + let fixed_islamic = Self::fixed_from_islamic(*date); + Iso::iso_from_fixed(fixed_islamic) } fn months_in_year(&self, date: &Self::DateInner) -> u8 { @@ -985,7 +916,7 @@ impl Calendar for IslamicCivil { } fn offset_date(&self, date: &mut Self::DateInner, offset: DateDuration) { - date.0.offset_date(offset, &self.precomputed_data()) + date.0.offset_date(offset, &()) } fn until( @@ -1000,7 +931,7 @@ impl Calendar for IslamicCivil { } fn debug_name(&self) -> &'static str { - Self::DEBUG_NAME + "Islamic (civil)" } fn year(&self, date: &Self::DateInner) -> types::FormattableYear { @@ -1008,7 +939,7 @@ impl Calendar for IslamicCivil { } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { - Self::is_leap_year(date.0.year, date.0.year_info) + Self::is_leap_year(date.0.year, ()) } fn month(&self, date: &Self::DateInner) -> types::FormattableMonth { @@ -1026,7 +957,7 @@ impl Calendar for IslamicCivil { day_of_year: date.0.day_of_year(), days_in_year: date.0.days_in_year(), prev_year: Self::year_as_islamic(prev_year), - days_in_prev_year: date.0.year_info.days_in_prev_year(), + days_in_prev_year: Self::days_in_provided_year(prev_year, ()), next_year: Self::year_as_islamic(next_year), } } @@ -1036,8 +967,24 @@ impl Calendar for IslamicCivil { } impl IslamicCivil { - fn precomputed_data(&self) -> IslamicPrecomputedData { - IslamicPrecomputedData::new(self.data.as_ref().map(|x| x.get())) + fn fixed_from_islamic(i_date: IslamicCivilDateInner) -> RataDie { + calendrical_calculations::islamic::fixed_from_islamic_civil( + i_date.0.year, + i_date.0.month, + i_date.0.day, + ) + } + + fn islamic_from_fixed(date: RataDie) -> Date { + let (y, m, d) = calendrical_calculations::islamic::islamic_civil_from_fixed(date); + + debug_assert!( + Date::try_new_islamic_civil_date_with_calendar(y, m, d, IslamicCivil).is_ok() + ); + Date::from_raw( + IslamicCivilDateInner(ArithmeticDate::new_unchecked(y, m, d)), + IslamicCivil, + ) } fn year_as_islamic(year: i32) -> types::FormattableYear { @@ -1048,7 +995,6 @@ impl IslamicCivil { related_iso: None, } } - pub(crate) const DEBUG_NAME: &'static str = "Islamic (civil)"; } impl> Date { @@ -1076,11 +1022,7 @@ impl> Date { day: u8, calendar: A, ) -> Result, CalendarError> { - let year_info = calendar - .as_calendar() - .precomputed_data() - .load_or_compute_info(year); - ArithmeticDate::new_from_ordinals_with_info(year, month, day, year_info) + ArithmeticDate::new_from_ordinals(year, month, day) .map(IslamicCivilDateInner) .map(|inner| Date::from_raw(inner, calendar)) } @@ -1130,29 +1072,40 @@ impl> DateTime { pub struct IslamicTabularDateInner(ArithmeticDate); impl CalendarArithmetic for IslamicTabular { - type YearInfo = IslamicYearInfo; - - fn month_days(_year: i32, month: u8, year_info: IslamicYearInfo) -> u8 { - year_info.packed_data.days_in_month(month) + type YearInfo = (); + + fn month_days(year: i32, month: u8, _data: ()) -> u8 { + match month { + 1 | 3 | 5 | 7 | 9 | 11 => 30, + 2 | 4 | 6 | 8 | 10 => 29, + 12 if Self::is_leap_year(year, ()) => 30, + 12 => 29, + _ => 0, + } } - fn months_for_every_year(_year: i32, _year_info: IslamicYearInfo) -> u8 { + fn months_for_every_year(_year: i32, _data: ()) -> u8 { 12 } - fn days_in_provided_year(_year: i32, year_info: IslamicYearInfo) -> u16 { - year_info.packed_data.days_in_year() + fn days_in_provided_year(year: i32, _data: ()) -> u16 { + if Self::is_leap_year(year, ()) { + 355 + } else { + 354 + } } - // As an true lunar calendar, it does not have leap years. - fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { - false + fn is_leap_year(year: i32, _data: ()) -> bool { + (14 + 11 * year).rem_euclid(30) < 11 } - fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { - let days = Self::month_days(year, 12, year_info); - - (12, days) + fn last_month_day_in_year(year: i32, _data: ()) -> (u8, u8) { + if Self::is_leap_year(year, ()) { + (12, 30) + } else { + (12, 29) + } } } @@ -1175,38 +1128,17 @@ impl Calendar for IslamicTabular { return Err(CalendarError::UnknownEra(era.0, self.debug_name())); }; - let month = if let Some((ordinal, false)) = month_code.parsed() { - ordinal - } else { - return Err(CalendarError::UnknownMonthCode( - month_code.0, - self.debug_name(), - )); - }; - ArithmeticDate::new_from_ordinals_with_info( - year, - month, - day, - self.precomputed_data().load_or_compute_info(year), - ) - .map(IslamicTabularDateInner) + ArithmeticDate::new_from_codes(self, year, month_code, day).map(IslamicTabularDateInner) } fn date_from_iso(&self, iso: Date) -> Self::DateInner { let fixed_iso = Iso::fixed_from_iso(*iso.inner()); - - let (year_info, y, m, d) = self - .precomputed_data() - .load_or_compute_info_for_iso(fixed_iso); - IslamicTabularDateInner(ArithmeticDate::new_unchecked_with_info(y, m, d, year_info)) + Self::islamic_from_fixed(fixed_iso).inner } fn date_to_iso(&self, date: &Self::DateInner) -> Date { - let fixed = - date.0 - .year_info - .rd_for::(date.0.year, date.0.month, date.0.day); - Iso::iso_from_fixed(fixed) + let fixed_islamic = Self::fixed_from_islamic(*date); + Iso::iso_from_fixed(fixed_islamic) } fn months_in_year(&self, date: &Self::DateInner) -> u8 { @@ -1226,7 +1158,7 @@ impl Calendar for IslamicTabular { } fn offset_date(&self, date: &mut Self::DateInner, offset: DateDuration) { - date.0.offset_date(offset, &self.precomputed_data()) + date.0.offset_date(offset, &()) } fn until( @@ -1241,7 +1173,7 @@ impl Calendar for IslamicTabular { } fn debug_name(&self) -> &'static str { - Self::DEBUG_NAME + "Islamic (tabular)" } fn year(&self, date: &Self::DateInner) -> types::FormattableYear { @@ -1249,7 +1181,7 @@ impl Calendar for IslamicTabular { } fn is_in_leap_year(&self, date: &Self::DateInner) -> bool { - Self::is_leap_year(date.0.year, date.0.year_info) + Self::is_leap_year(date.0.year, ()) } fn month(&self, date: &Self::DateInner) -> types::FormattableMonth { @@ -1267,7 +1199,7 @@ impl Calendar for IslamicTabular { day_of_year: date.0.day_of_year(), days_in_year: date.0.days_in_year(), prev_year: Self::year_as_islamic(prev_year), - days_in_prev_year: date.0.year_info.days_in_prev_year(), + days_in_prev_year: Self::days_in_provided_year(prev_year, ()), next_year: Self::year_as_islamic(next_year), } } @@ -1277,8 +1209,24 @@ impl Calendar for IslamicTabular { } impl IslamicTabular { - fn precomputed_data(&self) -> IslamicPrecomputedData { - IslamicPrecomputedData::new(self.data.as_ref().map(|x| x.get())) + fn fixed_from_islamic(i_date: IslamicTabularDateInner) -> RataDie { + calendrical_calculations::islamic::fixed_from_islamic_tabular( + i_date.0.year, + i_date.0.month, + i_date.0.day, + ) + } + + fn islamic_from_fixed(date: RataDie) -> Date { + let (y, m, d) = calendrical_calculations::islamic::islamic_tabular_from_fixed(date); + + debug_assert!( + Date::try_new_islamic_civil_date_with_calendar(y, m, d, IslamicCivil).is_ok() + ); + Date::from_raw( + IslamicTabularDateInner(ArithmeticDate::new_unchecked(y, m, d)), + IslamicTabular, + ) } fn year_as_islamic(year: i32) -> types::FormattableYear { @@ -1289,7 +1237,6 @@ impl IslamicTabular { related_iso: None, } } - pub(crate) const DEBUG_NAME: &'static str = "Islamic (tabular)"; } impl> Date { @@ -1317,11 +1264,7 @@ impl> Date { day: u8, calendar: A, ) -> Result, CalendarError> { - let year_info = calendar - .as_calendar() - .precomputed_data() - .load_or_compute_info(year); - ArithmeticDate::new_from_ordinals_with_info(year, month, day, year_info) + ArithmeticDate::new_from_ordinals(year, month, day) .map(IslamicTabularDateInner) .map(|inner| Date::from_raw(inner, calendar)) } diff --git a/components/calendar/src/provider.rs b/components/calendar/src/provider.rs index 16719d8de8b..18853db7517 100644 --- a/components/calendar/src/provider.rs +++ b/components/calendar/src/provider.rs @@ -18,10 +18,7 @@ pub mod chinese_based; pub mod islamic; pub use chinese_based::{ChineseCacheV1Marker, DangiCacheV1Marker}; -pub use islamic::{ - IslamicCivilCacheV1Marker, IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, - IslamicUmmAlQuraCacheV1Marker, -}; +pub use islamic::{IslamicObservationalCacheV1Marker, IslamicUmmAlQuraCacheV1Marker}; use crate::types::IsoWeekday; use core::str::FromStr; @@ -50,10 +47,8 @@ const _: () = { icu_calendar_data::make_provider!(Baked); icu_calendar_data::impl_calendar_chinesecache_v1!(Baked); icu_calendar_data::impl_calendar_dangicache_v1!(Baked); - icu_calendar_data::impl_calendar_islamiccivilcache_v1!(Baked); icu_calendar_data::impl_calendar_islamicobservationalcache_v1!(Baked); icu_calendar_data::impl_calendar_islamicummalquracache_v1!(Baked); - icu_calendar_data::impl_calendar_islamictabularcache_v1!(Baked); icu_calendar_data::impl_calendar_japanese_v1!(Baked); icu_calendar_data::impl_calendar_japanext_v1!(Baked); icu_calendar_data::impl_datetime_week_data_v1!(Baked); @@ -65,10 +60,8 @@ const _: () = { pub const KEYS: &[DataKey] = &[ ChineseCacheV1Marker::KEY, DangiCacheV1Marker::KEY, - IslamicCivilCacheV1Marker::KEY, IslamicObservationalCacheV1Marker::KEY, IslamicUmmAlQuraCacheV1Marker::KEY, - IslamicTabularCacheV1Marker::KEY, JapaneseErasV1Marker::KEY, JapaneseExtendedErasV1Marker::KEY, WeekDataV2Marker::KEY, diff --git a/components/calendar/src/provider/islamic.rs b/components/calendar/src/provider/islamic.rs index 2f74b1da97e..3715ab2e87f 100644 --- a/components/calendar/src/provider/islamic.rs +++ b/components/calendar/src/provider/islamic.rs @@ -28,16 +28,10 @@ use zerovec::ZeroVec; "calendar/islamicobservationalcache@1", singleton ), - marker(IslamicCivilCacheV1Marker, "calendar/islamiccivilcache@1", singleton), marker( IslamicUmmAlQuraCacheV1Marker, "calendar/islamicummalquracache@1", singleton - ), - marker( - IslamicTabularCacheV1Marker, - "calendar/islamictabularcache@1", - singleton ) )] #[derive(Debug, PartialEq, Clone, Default)] diff --git a/components/datetime/src/any/date.rs b/components/datetime/src/any/date.rs index b703965e93e..910d8592125 100644 --- a/components/datetime/src/any/date.rs +++ b/components/datetime/src/any/date.rs @@ -9,9 +9,9 @@ use crate::{input::DateInput, DateTimeError, FormattedDateTime}; use alloc::string::String; use icu_calendar::any_calendar::AnyCalendar; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, - IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, - JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, + WeekDataV1Marker, }; use icu_decimal::provider::DecimalSymbolsV1Marker; use icu_plurals::provider::OrdinalV1Marker; @@ -188,10 +188,8 @@ impl DateFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/any/datetime.rs b/components/datetime/src/any/datetime.rs index 286a60416bc..bfefea80669 100644 --- a/components/datetime/src/any/datetime.rs +++ b/components/datetime/src/any/datetime.rs @@ -9,9 +9,9 @@ use crate::{input::DateTimeInput, DateTimeError, FormattedDateTime}; use alloc::string::String; use icu_calendar::any_calendar::AnyCalendar; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, - IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, - JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, + WeekDataV1Marker, }; use icu_decimal::provider::DecimalSymbolsV1Marker; use icu_plurals::provider::OrdinalV1Marker; @@ -242,10 +242,8 @@ impl DateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider @@ -393,10 +391,8 @@ impl DateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/any/zoned_datetime.rs b/components/datetime/src/any/zoned_datetime.rs index e239c23d238..1f14fa9679d 100644 --- a/components/datetime/src/any/zoned_datetime.rs +++ b/components/datetime/src/any/zoned_datetime.rs @@ -14,9 +14,9 @@ use crate::time_zone::TimeZoneFormatterOptions; use crate::{DateTimeError, FormattedZonedDateTime}; use icu_calendar::any_calendar::{AnyCalendar, AnyCalendarKind}; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, - IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, - JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV1Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, + WeekDataV1Marker, }; use icu_calendar::{DateTime, Time}; use icu_decimal::provider::DecimalSymbolsV1Marker; @@ -258,10 +258,8 @@ impl ZonedDateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider @@ -416,10 +414,8 @@ impl ZonedDateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/components/datetime/src/external_loaders.rs b/components/datetime/src/external_loaders.rs index 736ced15d75..c64758db13e 100644 --- a/components/datetime/src/external_loaders.rs +++ b/components/datetime/src/external_loaders.rs @@ -207,10 +207,8 @@ where + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + ?Sized, { #[inline] diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index 5cd8796c1d6..5c225b628dd 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -21,9 +21,9 @@ use crate::Error; use core::fmt; use core::marker::PhantomData; use icu_calendar::provider::{ - ChineseCacheV1Marker, DangiCacheV1Marker, IslamicCivilCacheV1Marker, - IslamicObservationalCacheV1Marker, IslamicTabularCacheV1Marker, IslamicUmmAlQuraCacheV1Marker, - JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, WeekDataV2Marker, + ChineseCacheV1Marker, DangiCacheV1Marker, IslamicObservationalCacheV1Marker, + IslamicUmmAlQuraCacheV1Marker, JapaneseErasV1Marker, JapaneseExtendedErasV1Marker, + WeekDataV2Marker, }; use icu_calendar::AnyCalendar; use icu_decimal::provider::DecimalSymbolsV1Marker; @@ -511,10 +511,8 @@ impl NeoDateFormatter { // AnyCalendar constructor keys + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider // FixedDecimalFormatter keys @@ -1475,10 +1473,8 @@ impl NeoDateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider @@ -1651,10 +1647,8 @@ impl NeoDateTimeFormatter { // AnyCalendar constructor keys + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider // FixedDecimalFormatter keys @@ -1782,10 +1776,8 @@ impl NeoDateTimeFormatter { + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider - + DataProvider + DataProvider + DataProvider + DataProvider diff --git a/provider/baked/calendar/data/macros.rs b/provider/baked/calendar/data/macros.rs index 6651504d6e7..3515cae0583 100644 --- a/provider/baked/calendar/data/macros.rs +++ b/provider/baked/calendar/data/macros.rs @@ -36,21 +36,11 @@ mod calendar_dangicache_v1; #[doc(inline)] pub use __impl_calendar_dangicache_v1 as impl_calendar_dangicache_v1; #[macro_use] -#[path = "macros/calendar_islamiccivilcache_v1.rs.data"] -mod calendar_islamiccivilcache_v1; -#[doc(inline)] -pub use __impl_calendar_islamiccivilcache_v1 as impl_calendar_islamiccivilcache_v1; -#[macro_use] #[path = "macros/calendar_islamicobservationalcache_v1.rs.data"] mod calendar_islamicobservationalcache_v1; #[doc(inline)] pub use __impl_calendar_islamicobservationalcache_v1 as impl_calendar_islamicobservationalcache_v1; #[macro_use] -#[path = "macros/calendar_islamictabularcache_v1.rs.data"] -mod calendar_islamictabularcache_v1; -#[doc(inline)] -pub use __impl_calendar_islamictabularcache_v1 as impl_calendar_islamictabularcache_v1; -#[macro_use] #[path = "macros/calendar_islamicummalquracache_v1.rs.data"] mod calendar_islamicummalquracache_v1; #[doc(inline)] diff --git a/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data b/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data deleted file mode 100644 index b459e2fd073..00000000000 --- a/provider/baked/calendar/data/macros/calendar_islamiccivilcache_v1.rs.data +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -/// Implement `DataProvider` on the given struct using the data -/// hardcoded in this file. This allows the struct to be used with -/// `icu`'s `_unstable` constructors. -#[doc(hidden)] -#[macro_export] -macro_rules! __impl_calendar_islamiccivilcache_v1 { - ($ provider : ty) => { - #[clippy::msrv = "1.67"] - const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; - #[clippy::msrv = "1.67"] - impl $provider { - #[doc(hidden)] - pub const SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; - } - #[clippy::msrv = "1.67"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { - if req.locale.is_empty() { - Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1)), metadata: Default::default() }) - } else { - Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) - } - } - } - }; -} diff --git a/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data b/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data deleted file mode 100644 index f732a88b438..00000000000 --- a/provider/baked/calendar/data/macros/calendar_islamictabularcache_v1.rs.data +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -/// Implement `DataProvider` on the given struct using the data -/// hardcoded in this file. This allows the struct to be used with -/// `icu`'s `_unstable` constructors. -#[doc(hidden)] -#[macro_export] -macro_rules! __impl_calendar_islamictabularcache_v1 { - ($ provider : ty) => { - #[clippy::msrv = "1.67"] - const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; - #[clippy::msrv = "1.67"] - impl $provider { - #[doc(hidden)] - pub const SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; - } - #[clippy::msrv = "1.67"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { - if req.locale.is_empty() { - Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1)), metadata: Default::default() }) - } else { - Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) - } - } - } - }; -} diff --git a/provider/datagen/src/registry.rs b/provider/datagen/src/registry.rs index cf180e3e5f9..b22359397bf 100644 --- a/provider/datagen/src/registry.rs +++ b/provider/datagen/src/registry.rs @@ -141,11 +141,9 @@ registry!( icu_calendar::provider::ChineseCacheV1Marker = "calendar/chinesecache@1", icu_calendar::provider::DangiCacheV1Marker = "calendar/dangicache@1", icu_calendar::provider::JapaneseErasV1Marker = "calendar/japanese@1", - icu_calendar::provider::IslamicCivilCacheV1Marker = "calendar/islamiccivilcache@1", icu_calendar::provider::IslamicObservationalCacheV1Marker = "calendar/islamicobservationalcache@1", icu_calendar::provider::IslamicUmmAlQuraCacheV1Marker = "calendar/islamicummalquracache@1", - icu_calendar::provider::IslamicTabularCacheV1Marker = "calendar/islamictabularcache@1", icu_calendar::provider::JapaneseExtendedErasV1Marker = "calendar/japanext@1", icu_calendar::provider::WeekDataV1Marker = "datetime/week_data@1", icu_calendar::provider::WeekDataV2Marker = "datetime/week_data@2", diff --git a/provider/datagen/src/transform/cldr/calendar/islamic.rs b/provider/datagen/src/transform/cldr/calendar/islamic.rs index 0bd4e4985c4..574df8284cd 100644 --- a/provider/datagen/src/transform/cldr/calendar/islamic.rs +++ b/provider/datagen/src/transform/cldr/calendar/islamic.rs @@ -3,8 +3,7 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use calendrical_calculations::islamic::{ - CivilIslamicMarker, IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, - TabularIslamicMarker, + IslamicBasedMarker, ObservationalIslamicMarker, SaudiIslamicMarker, }; use calendrical_calculations::iso; use icu_calendar::provider::islamic::*; @@ -40,23 +39,6 @@ impl IterableDataProvider for crate::DatagenP } } -impl DataProvider for crate::DatagenProvider { - fn load(&self, req: DataRequest) -> Result, DataError> { - self.check_req::(req)?; - let cache = load::(); - Ok(DataResponse { - metadata: DataResponseMetadata::default(), - payload: Some(DataPayload::from_owned(cache)), - }) - } -} - -impl IterableDataProvider for crate::DatagenProvider { - fn supported_locales(&self) -> Result, DataError> { - Ok(vec![Default::default()]) - } -} - impl DataProvider for crate::DatagenProvider { fn load( &self, @@ -76,23 +58,3 @@ impl IterableDataProvider for crate::DatagenProvi Ok(vec![Default::default()]) } } - -impl DataProvider for crate::DatagenProvider { - fn load( - &self, - req: DataRequest, - ) -> Result, DataError> { - self.check_req::(req)?; - let cache = load::(); - Ok(DataResponse { - metadata: DataResponseMetadata::default(), - payload: Some(DataPayload::from_owned(cache)), - }) - } -} - -impl IterableDataProvider for crate::DatagenProvider { - fn supported_locales(&self) -> Result, DataError> { - Ok(vec![Default::default()]) - } -} diff --git a/provider/datagen/tests/data/baked/macros.rs b/provider/datagen/tests/data/baked/macros.rs index 9670bcefd84..df38988f05c 100644 --- a/provider/datagen/tests/data/baked/macros.rs +++ b/provider/datagen/tests/data/baked/macros.rs @@ -36,21 +36,11 @@ mod calendar_dangicache_v1; #[doc(inline)] pub use __impl_calendar_dangicache_v1 as impl_calendar_dangicache_v1; #[macro_use] -#[path = "macros/calendar_islamiccivilcache_v1.rs.data"] -mod calendar_islamiccivilcache_v1; -#[doc(inline)] -pub use __impl_calendar_islamiccivilcache_v1 as impl_calendar_islamiccivilcache_v1; -#[macro_use] #[path = "macros/calendar_islamicobservationalcache_v1.rs.data"] mod calendar_islamicobservationalcache_v1; #[doc(inline)] pub use __impl_calendar_islamicobservationalcache_v1 as impl_calendar_islamicobservationalcache_v1; #[macro_use] -#[path = "macros/calendar_islamictabularcache_v1.rs.data"] -mod calendar_islamictabularcache_v1; -#[doc(inline)] -pub use __impl_calendar_islamictabularcache_v1 as impl_calendar_islamictabularcache_v1; -#[macro_use] #[path = "macros/calendar_islamicummalquracache_v1.rs.data"] mod calendar_islamicummalquracache_v1; #[doc(inline)] diff --git a/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data b/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data deleted file mode 100644 index b459e2fd073..00000000000 --- a/provider/datagen/tests/data/baked/macros/calendar_islamiccivilcache_v1.rs.data +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -/// Implement `DataProvider` on the given struct using the data -/// hardcoded in this file. This allows the struct to be used with -/// `icu`'s `_unstable` constructors. -#[doc(hidden)] -#[macro_export] -macro_rules! __impl_calendar_islamiccivilcache_v1 { - ($ provider : ty) => { - #[clippy::msrv = "1.67"] - const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; - #[clippy::msrv = "1.67"] - impl $provider { - #[doc(hidden)] - pub const SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; - } - #[clippy::msrv = "1.67"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { - if req.locale.is_empty() { - Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICCIVILCACHE_V1)), metadata: Default::default() }) - } else { - Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) - } - } - } - }; -} diff --git a/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data b/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data deleted file mode 100644 index f732a88b438..00000000000 --- a/provider/datagen/tests/data/baked/macros/calendar_islamictabularcache_v1.rs.data +++ /dev/null @@ -1,27 +0,0 @@ -// @generated -/// Implement `DataProvider` on the given struct using the data -/// hardcoded in this file. This allows the struct to be used with -/// `icu`'s `_unstable` constructors. -#[doc(hidden)] -#[macro_export] -macro_rules! __impl_calendar_islamictabularcache_v1 { - ($ provider : ty) => { - #[clippy::msrv = "1.67"] - const _: () = <$provider>::MUST_USE_MAKE_PROVIDER_MACRO; - #[clippy::msrv = "1.67"] - impl $provider { - #[doc(hidden)] - pub const SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1: &'static ::Yokeable = &icu::calendar::provider::islamic::IslamicCacheV1 { first_extended_year: 1317i32, data: unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"U\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05U\rU\x05U\x05U\rU\x05U\x05U\rU\x05U\x05U=U\x05") } }; - } - #[clippy::msrv = "1.67"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { - if req.locale.is_empty() { - Ok(icu_provider::DataResponse { payload: Some(icu_provider::DataPayload::from_static_ref(Self::SINGLETON_CALENDAR_ISLAMICTABULARCACHE_V1)), metadata: Default::default() }) - } else { - Err(icu_provider::DataErrorKind::ExtraneousLocale.with_req(::KEY, req)) - } - } - } - }; -} diff --git a/provider/datagen/tests/data/baked/mod.rs b/provider/datagen/tests/data/baked/mod.rs index b20f2fade81..0a0e7d9ff25 100644 --- a/provider/datagen/tests/data/baked/mod.rs +++ b/provider/datagen/tests/data/baked/mod.rs @@ -5,9 +5,7 @@ macro_rules! impl_data_provider { make_provider!($provider); impl_calendar_chinesecache_v1!($provider); impl_calendar_dangicache_v1!($provider); - impl_calendar_islamiccivilcache_v1!($provider); impl_calendar_islamicobservationalcache_v1!($provider); - impl_calendar_islamictabularcache_v1!($provider); impl_calendar_islamicummalquracache_v1!($provider); impl_calendar_japanese_v1!($provider); impl_calendar_japanext_v1!($provider); @@ -300,9 +298,7 @@ macro_rules! impl_any_provider { match key.hashed() { h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), - h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), - h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::KEY.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), diff --git a/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json b/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json deleted file mode 100644 index 08bd4ba979c..00000000000 --- a/provider/datagen/tests/data/json/calendar/islamiccivilcache@1/und.json +++ /dev/null @@ -1,1005 +0,0 @@ -{ - "first_extended_year": 1317, - "data": [ - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ] - ] -} diff --git a/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json b/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json deleted file mode 100644 index 08bd4ba979c..00000000000 --- a/provider/datagen/tests/data/json/calendar/islamictabularcache@1/und.json +++ /dev/null @@ -1,1005 +0,0 @@ -{ - "first_extended_year": 1317, - "data": [ - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 13 - ], - [ - 85, - 5 - ], - [ - 85, - 5 - ], - [ - 85, - 61 - ], - [ - 85, - 5 - ] - ] -} diff --git a/provider/datagen/tests/data/postcard/fingerprints.csv b/provider/datagen/tests/data/postcard/fingerprints.csv index b791b775e21..e0ea67a6112 100644 --- a/provider/datagen/tests/data/postcard/fingerprints.csv +++ b/provider/datagen/tests/data/postcard/fingerprints.csv @@ -1,8 +1,6 @@ calendar/chinesecache@1, und, 754B, c116ab2a7479b26d calendar/dangicache@1, und, 754B, d7565838cc8c6aa6 -calendar/islamiccivilcache@1, und, 504B, b558648c456bc311 calendar/islamicobservationalcache@1, und, 504B, 31c8968bfd922ede -calendar/islamictabularcache@1, und, 504B, b558648c456bc311 calendar/islamicummalquracache@1, und, 504B, ef6ac9ff14fd3f3 calendar/japanese@1, und, 111B, b31e52deaf52706f calendar/japanext@1, und, 5216B, 6c20e216c8cd6e41 From 8187d3fd766fa8842369eb3fc4822f41cf22ca39 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 11 Apr 2024 16:48:28 -0700 Subject: [PATCH 3/5] use consistent definition of leap year --- components/calendar/src/islamic.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/calendar/src/islamic.rs b/components/calendar/src/islamic.rs index 19c822f26ca..954671c4aa3 100644 --- a/components/calendar/src/islamic.rs +++ b/components/calendar/src/islamic.rs @@ -111,7 +111,7 @@ pub struct IslamicUmmAlQura { pub struct IslamicTabular; impl IslamicObservational { - /// Creates a new [`IslamicObservational`] with some precomputed calendrical calculations. + /// Creates a new [`IslamicObservational`] with some compiled data containing precomputed calendrical calculations. /// /// ✨ *Enabled with the `compiled_data` Cargo feature.* /// @@ -164,7 +164,7 @@ impl IslamicCivil { } impl IslamicUmmAlQura { - /// Creates a new [`IslamicUmmAlQura`] with some precomputed calendrical calculations. + /// Creates a new [`IslamicUmmAlQura`] with some compiled data containing precomputed calendrical calculations. /// /// ✨ *Enabled with the `compiled_data` Cargo feature.* /// @@ -373,8 +373,8 @@ impl CalendarArithmetic for IslamicObservational { } // As an true lunar calendar, it does not have leap years. - fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { - false + fn is_leap_year(_year: i32, year_info: IslamicYearInfo) -> bool { + year_info.packed_data.days_in_year() != IslamicYearInfo::SHORT_YEAR_LEN } fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { @@ -609,8 +609,8 @@ impl CalendarArithmetic for IslamicUmmAlQura { } // As an true lunar calendar, it does not have leap years. - fn is_leap_year(_year: i32, _year_info: IslamicYearInfo) -> bool { - false + fn is_leap_year(_year: i32, year_info: IslamicYearInfo) -> bool { + year_info.packed_data.days_in_year() != IslamicYearInfo::SHORT_YEAR_LEN } fn last_month_day_in_year(year: i32, year_info: IslamicYearInfo) -> (u8, u8) { From b64d374ebad1c864457afc506da4d2dc08da578c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 19 Apr 2024 11:41:05 -0700 Subject: [PATCH 4/5] Reintroduce derives and exhaustive --- components/calendar/benches/convert.rs | 4 ++-- components/calendar/benches/date.rs | 8 ++++---- components/calendar/benches/datetime.rs | 8 ++++---- components/calendar/src/any_calendar.rs | 4 ++-- components/calendar/src/islamic.rs | 6 ++++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/components/calendar/benches/convert.rs b/components/calendar/benches/convert.rs index 51e3023528a..88d641b6a3e 100644 --- a/components/calendar/benches/convert.rs +++ b/components/calendar/benches/convert.rs @@ -89,7 +89,7 @@ fn convert_benches(c: &mut Criterion) { bench_calendar( &mut group, "calendar/islamic/civil", - icu::calendar::islamic::IslamicCivil::new_always_calculating(), + icu::calendar::islamic::IslamicCivil::new(), ); #[cfg(feature = "bench")] @@ -103,7 +103,7 @@ fn convert_benches(c: &mut Criterion) { bench_calendar( &mut group, "calendar/islamic/tabular", - icu::calendar::islamic::IslamicTabular::new_always_calculating(), + icu::calendar::islamic::IslamicTabular::new(), ); group.finish(); diff --git a/components/calendar/benches/date.rs b/components/calendar/benches/date.rs index 332e27ea920..c2153de5219 100644 --- a/components/calendar/benches/date.rs +++ b/components/calendar/benches/date.rs @@ -222,13 +222,13 @@ fn date_benches(c: &mut Criterion) { &mut group, "calendar/islamic/civil", &fxs, - icu::calendar::islamic::IslamicCivil::new_always_calculating(), + icu::calendar::islamic::IslamicCivil::new(), |y, m, d| { Date::try_new_islamic_civil_date_with_calendar( y, m, d, - icu::calendar::islamic::IslamicCivil::new_always_calculating(), + icu::calendar::islamic::IslamicCivil::new(), ) .unwrap() }, @@ -239,13 +239,13 @@ fn date_benches(c: &mut Criterion) { &mut group, "calendar/islamic/tabular", &fxs, - icu::calendar::islamic::IslamicTabular::new_always_calculating(), + icu::calendar::islamic::IslamicTabular::new(), |y, m, d| { Date::try_new_islamic_tabular_date_with_calendar( y, m, d, - icu::calendar::islamic::IslamicTabular::new_always_calculating(), + icu::calendar::islamic::IslamicTabular::new(), ) .unwrap() }, diff --git a/components/calendar/benches/datetime.rs b/components/calendar/benches/datetime.rs index d0ad9b25c18..20fd6e1f9b8 100644 --- a/components/calendar/benches/datetime.rs +++ b/components/calendar/benches/datetime.rs @@ -186,7 +186,7 @@ fn datetime_benches(c: &mut Criterion) { &mut group, "calendar/islamic/civil", &fxs, - icu::calendar::islamic::IslamicCivil::new_always_calculating(), + icu::calendar::islamic::IslamicCivil::new(), |y, m, d, h, min, s| { DateTime::try_new_islamic_civil_datetime_with_calendar( y, @@ -195,7 +195,7 @@ fn datetime_benches(c: &mut Criterion) { h, min, s, - icu::calendar::islamic::IslamicCivil::new_always_calculating(), + icu::calendar::islamic::IslamicCivil::new(), ) .unwrap() }, @@ -206,7 +206,7 @@ fn datetime_benches(c: &mut Criterion) { &mut group, "calendar/islamic/tabular", &fxs, - icu::calendar::islamic::IslamicTabular::new_always_calculating(), + icu::calendar::islamic::IslamicTabular::new(), |y, m, d, h, min, s| { DateTime::try_new_islamic_tabular_datetime_with_calendar( y, @@ -215,7 +215,7 @@ fn datetime_benches(c: &mut Criterion) { h, min, s, - icu::calendar::islamic::IslamicTabular::new_always_calculating(), + icu::calendar::islamic::IslamicTabular::new(), ) .unwrap() }, diff --git a/components/calendar/src/any_calendar.rs b/components/calendar/src/any_calendar.rs index ac310253ca8..e0aa97a6ab9 100644 --- a/components/calendar/src/any_calendar.rs +++ b/components/calendar/src/any_calendar.rs @@ -1234,7 +1234,7 @@ impl IntoAnyCalendar for IslamicCivil { AnyCalendar::IslamicCivil(self) } fn to_any_cloned(&self) -> AnyCalendar { - AnyCalendar::IslamicCivil(self.clone()) + AnyCalendar::IslamicCivil(*self) } fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner { AnyDateInner::IslamicCivil(*d) @@ -1258,7 +1258,7 @@ impl IntoAnyCalendar for IslamicTabular { AnyCalendar::IslamicTabular(self) } fn to_any_cloned(&self) -> AnyCalendar { - AnyCalendar::IslamicTabular(self.clone()) + AnyCalendar::IslamicTabular(*self) } fn date_to_any(&self, d: &Self::DateInner) -> AnyDateInner { AnyDateInner::IslamicTabular(*d) diff --git a/components/calendar/src/islamic.rs b/components/calendar/src/islamic.rs index 954671c4aa3..9252af9c213 100644 --- a/components/calendar/src/islamic.rs +++ b/components/calendar/src/islamic.rs @@ -79,7 +79,8 @@ pub struct IslamicObservational { /// /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. -#[derive(Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[allow(clippy::exhaustive_structs)] // unit struct pub struct IslamicCivil; /// Umm al-Qura Hijri Calendar (Used in Saudi Arabia) @@ -107,7 +108,8 @@ pub struct IslamicUmmAlQura { /// /// This calendar is a pure lunar calendar with no leap months. It uses month codes /// `"M01" - "M12"`. -#[derive(Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, Hash, Eq, PartialEq, PartialOrd, Ord)] +#[allow(clippy::exhaustive_structs)] // unit struct pub struct IslamicTabular; impl IslamicObservational { From 02c3b5e89782251f8d59d4416abfbf4dad86c703 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 19 Apr 2024 13:33:47 -0700 Subject: [PATCH 5/5] fixes --- components/datetime/tests/datetime.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index 079761af043..2557c3b2931 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -79,11 +79,10 @@ fn test_fixture(fixture_name: &str, file: &str) { input_value.to_calendar(Ethiopian::new_with_era_style(EthiopianEraStyle::AmeteAlem)); let input_hebrew = input_value.to_calendar(Hebrew); let input_indian = input_value.to_calendar(Indian); - let input_islamic_civil = input_value.to_calendar(IslamicCivil::new_always_calculating()); + let input_islamic_civil = input_value.to_calendar(IslamicCivil); let input_islamic_observational = input_value.to_calendar(IslamicObservational::new_always_calculating()); - let input_islamic_tabular = - input_value.to_calendar(IslamicTabular::new_always_calculating()); + let input_islamic_tabular = input_value.to_calendar(IslamicTabular); let input_islamic_umm_al_qura = input_value.to_calendar(IslamicUmmAlQura::new_always_calculating()); let input_iso = input_value.to_calendar(Iso);