diff --git a/components/datetime/README.md b/components/datetime/README.md index 5807bdc060e..c7cd246fc9c 100644 --- a/components/datetime/README.md +++ b/components/datetime/README.md @@ -12,7 +12,7 @@ allow it to collect necessary data from the [data provider], and once instantiat used to quickly format any date and time provided. There are variants of these types that can format greater or fewer components. These formatters work with types from the [`calendar`] module, like [`Date`], [`DateTime`], and [`Time`], -and [`timezone::CustomTimeZone`], however other types may be used provided they implement the traits from the [`input`] module. +and [`timezone::TimeZoneInfo`], however other types may be used provided they implement the traits from the [`input`] module. Each instance of a date-related formatter is associated with a particular [`Calendar`]. The "Typed" vs untyped formatter distinction is to help with this. For example, if you know at compile time that you @@ -69,7 +69,7 @@ assert_try_writeable_eq!(typed_formatted_date, "Sep 12, 2020, 12:34 PM"); [`Time`]: calendar::types::{Time} [`Calendar`]: calendar::{Calendar} [`AnyCalendar`]: calendar::any_calendar::{AnyCalendar} -[`timezone::CustomTimeZone`]: icu::timezone::{CustomTimeZone} +[`timezone::TimeZoneInfo`]: icu::timezone::{TimeZoneInfo} diff --git a/components/datetime/benches/datetime.rs b/components/datetime/benches/datetime.rs index febe3daf03d..b4c3515cde2 100644 --- a/components/datetime/benches/datetime.rs +++ b/components/datetime/benches/datetime.rs @@ -9,7 +9,7 @@ use icu_datetime::neo::TypedNeoFormatter; use icu_calendar::{DateTime, Gregorian}; use icu_locale_core::Locale; -use icu_timezone::{CustomTimeZone, CustomZonedDateTime}; +use icu_timezone::{CustomZonedDateTime, TimeZoneInfo}; use writeable::TryWriteable; #[path = "../tests/mock.rs"] @@ -35,7 +35,7 @@ fn datetime_benches(c: &mut Criterion) { date, time, // zone is unused but we need to make the types match - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), } } }) diff --git a/components/datetime/src/format/datetime.rs b/components/datetime/src/format/datetime.rs index 4b52851ba0b..06373dddd9a 100644 --- a/components/datetime/src/format/datetime.rs +++ b/components/datetime/src/format/datetime.rs @@ -11,8 +11,10 @@ use crate::fields::{self, Day, Field, FieldLength, FieldSymbol, Second, Week, Ye use crate::input::ExtractedInput; use crate::pattern::runtime::PatternMetadata; use crate::pattern::PatternItem; -use crate::time_zone::{FormatTimeZone, FormatTimeZoneError, Iso8601Format}; -use crate::time_zone::{IsoFormat, IsoMinutes, IsoSeconds, ResolvedNeoTimeZoneSkeleton}; +use crate::time_zone::{ + FormatTimeZone, FormatTimeZoneError, Iso8601Format, IsoFormat, IsoMinutes, IsoSeconds, + ResolvedNeoTimeZoneSkeleton, +}; use core::fmt::{self, Write}; use fixed_decimal::FixedDecimal; @@ -471,27 +473,15 @@ where } Some(time_zone) => { let payloads = datetime_names.get_payloads(); - let mut r = Err(DateTimeWriteError::MissingNames(field)); + let mut r = Err(FormatTimeZoneError::Fallback); for formatter in time_zone.units() { match formatter.format(w, input, payloads, fdf)? { - Ok(()) => { - r = Ok(()); - break; - } Err(FormatTimeZoneError::Fallback) => { // Expected common case: the unit needs fall back to the next one continue; } - Err(FormatTimeZoneError::MissingInputField(f)) => { - r = Err(DateTimeWriteError::MissingInputField(f)); - break; - } - Err(FormatTimeZoneError::MissingZoneSymbols) => { - r = Err(DateTimeWriteError::MissingNames(field)); - break; - } - Err(FormatTimeZoneError::MissingFixedDecimalFormatter) => { - r = Err(DateTimeWriteError::MissingFixedDecimalFormatter); + r2 => { + r = r2; break; } } @@ -499,21 +489,44 @@ where match r { Ok(()) => Ok(()), - Err(DateTimeWriteError::MissingInputField(_)) => { + Err(FormatTimeZoneError::MissingInputField(f)) => { write_value_missing(w, field)?; - r + Err(DateTimeWriteError::MissingInputField(f)) } - _ => { - w.with_part(Part::ERROR, |w| match input.offset { - Some(offset) => Iso8601Format { - format: IsoFormat::Basic, - minutes: IsoMinutes::Required, - seconds: IsoSeconds::Optional, + Err( + e @ (FormatTimeZoneError::MissingFixedDecimalFormatter + | FormatTimeZoneError::MissingZoneSymbols), + ) => { + if let Some(offset) = input.offset { + w.with_part(Part::ERROR, |w| { + Iso8601Format { + format: IsoFormat::Basic, + minutes: IsoMinutes::Required, + seconds: IsoSeconds::Optional, + } + .format_infallible(w, offset) + })?; + } else { + write_value_missing(w, field)?; + } + Err(match e { + FormatTimeZoneError::MissingFixedDecimalFormatter => { + DateTimeWriteError::MissingFixedDecimalFormatter + } + FormatTimeZoneError::MissingZoneSymbols => { + DateTimeWriteError::MissingNames(field) } - .format_infallible(w, offset), - None => "{GMT+?}".write_to(w), + _ => unreachable!(), + }) + } + Err(FormatTimeZoneError::Fallback) => { + // unreachable because our current fallback chains don't fall through + w.with_part(Part::ERROR, |w| { + w.write_str("{unsupported:")?; + w.write_char(char::from(field.symbol))?; + w.write_str("}") })?; - r + Err(DateTimeWriteError::UnsupportedField(field)) } } } diff --git a/components/datetime/src/format/neo.rs b/components/datetime/src/format/neo.rs index 3200a18d467..fadea3f6ac2 100644 --- a/components/datetime/src/format/neo.rs +++ b/components/datetime/src/format/neo.rs @@ -65,6 +65,7 @@ impl_holder_trait!(tz::MzGenericLongV1Marker); impl_holder_trait!(tz::MzGenericShortV1Marker); impl_holder_trait!(tz::MzSpecificLongV1Marker); impl_holder_trait!(tz::MzSpecificShortV1Marker); +impl_holder_trait!(tz::MzPeriodV1Marker); #[non_exhaustive] pub enum MaybePayloadError2 { @@ -325,7 +326,7 @@ size_test!( /// use icu::datetime::neo_pattern::DateTimePattern; /// use icu::datetime::neo_skeleton::NeoSkeleton; /// use icu::locale::locale; -/// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; +/// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime}; /// use writeable::{Part, assert_try_writeable_parts_eq}; /// /// // Create an instance that can format all fields (NeoSkeleton): @@ -366,7 +367,7 @@ size_test!( /// use icu::datetime::neo_pattern::DateTimePattern; /// use icu::datetime::neo_skeleton::NeoTimeZoneSkeleton; /// use icu::locale::locale; -/// use icu::timezone::CustomTimeZone; +/// use icu::timezone::TimeZoneInfo; /// use writeable::{Part, assert_try_writeable_parts_eq}; /// /// // Create an instance that can format abbreviated month, weekday, and day period names: @@ -382,7 +383,7 @@ size_test!( /// // Further, the time zone we provide doesn't contain any offset into! /// // Missing data is filled in on a best-effort basis, and an error is signaled. /// assert_try_writeable_parts_eq!( -/// names.with_pattern(&pattern).format(&CustomTimeZone::unknown()), +/// names.with_pattern(&pattern).format(&TimeZoneInfo::unknown()), /// "It is: {E} {M} {d} {y} {G} at {h}:{m}:{s} {a} {z}", /// Err(DateTimeWriteError::MissingInputField("iso_weekday")), /// [ @@ -417,6 +418,7 @@ pub trait DateTimeNamesMarker { type ZoneGenericShort: DateTimeNamesHolderTrait; type ZoneSpecificLong: DateTimeNamesHolderTrait; type ZoneSpecificShort: DateTimeNamesHolderTrait; + type MetazoneLookup: DateTimeNamesHolderTrait; } #[derive(Debug)] @@ -433,6 +435,7 @@ impl DateTimeNamesMarker for DateMarker { type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } #[derive(Debug)] @@ -449,6 +452,7 @@ impl DateTimeNamesMarker for TimeMarker { type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } #[derive(Debug)] @@ -465,6 +469,7 @@ impl DateTimeNamesMarker for DateTimeMarker { type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } #[derive(Debug)] @@ -481,6 +486,7 @@ impl DateTimeNamesMarker for ZonedDateTimeMarker { type ZoneGenericShort = tz::MzGenericShortV1Marker; type ZoneSpecificLong = tz::MzSpecificLongV1Marker; type ZoneSpecificShort = tz::MzSpecificShortV1Marker; + type MetazoneLookup = tz::MzPeriodV1Marker; } impl From> for RawDateTimeNames { @@ -496,6 +502,7 @@ impl From> for RawDateTimeNames { mz_generic_short: (), mz_specific_long: (), mz_specific_short: (), + mz_periods: (), fixed_decimal_formatter: other.fixed_decimal_formatter, _marker: PhantomData, } @@ -515,6 +522,7 @@ impl From> for RawDateTimeNames { mz_generic_short: (), mz_specific_long: (), mz_specific_short: (), + mz_periods: (), fixed_decimal_formatter: other.fixed_decimal_formatter, _marker: PhantomData, } @@ -549,6 +557,7 @@ pub(crate) struct RawDateTimeNames { mz_specific_short: >::Container<()>, + mz_periods: >::Container<()>, // TODO(#4340): Make the FixedDecimalFormatter optional fixed_decimal_formatter: Option, _marker: PhantomData, @@ -585,6 +594,7 @@ pub(crate) struct RawDateTimeNamesBorrowed<'l> { mz_generic_short: OptionalNames<(), &'l tz::MzGenericV1<'l>>, mz_specific_long: OptionalNames<(), &'l tz::MzSpecificV1<'l>>, mz_specific_short: OptionalNames<(), &'l tz::MzSpecificV1<'l>>, + mz_periods: OptionalNames<(), &'l tz::MzPeriodV1<'l>>, pub(crate) fixed_decimal_formatter: Option<&'l FixedDecimalFormatter>, } @@ -1101,10 +1111,11 @@ impl TypedDateTimeNames { provider: &P, ) -> Result<&mut Self, SingleLoadError> where - P: DataProvider + ?Sized, + P: DataProvider + DataProvider + ?Sized, { self.inner.load_time_zone_generic_long_names( &tz::MzGenericLongV1Marker::bind(provider), + &tz::MzPeriodV1Marker::bind(provider), &self.locale, )?; Ok(self) @@ -1176,10 +1187,11 @@ impl TypedDateTimeNames { provider: &P, ) -> Result<&mut Self, SingleLoadError> where - P: DataProvider + ?Sized, + P: DataProvider + DataProvider + ?Sized, { self.inner.load_time_zone_generic_short_names( &tz::MzGenericShortV1Marker::bind(provider), + &tz::MzPeriodV1Marker::bind(provider), &self.locale, )?; Ok(self) @@ -1251,10 +1263,11 @@ impl TypedDateTimeNames { provider: &P, ) -> Result<&mut Self, SingleLoadError> where - P: DataProvider + ?Sized, + P: DataProvider + DataProvider + ?Sized, { self.inner.load_time_zone_specific_long_names( &tz::MzSpecificLongV1Marker::bind(provider), + &tz::MzPeriodV1Marker::bind(provider), &self.locale, )?; Ok(self) @@ -1326,10 +1339,11 @@ impl TypedDateTimeNames { provider: &P, ) -> Result<&mut Self, SingleLoadError> where - P: DataProvider + ?Sized, + P: DataProvider + DataProvider + ?Sized, { self.inner.load_time_zone_specific_short_names( &tz::MzSpecificShortV1Marker::bind(provider), + &tz::MzPeriodV1Marker::bind(provider), &self.locale, )?; Ok(self) @@ -1476,6 +1490,7 @@ impl TypedDateTimeNames { + DataProvider + DataProvider + DataProvider + + DataProvider + DataProvider + ?Sized, { @@ -1492,6 +1507,7 @@ impl TypedDateTimeNames { &tz::MzGenericShortV1Marker::bind(provider), &tz::MzSpecificLongV1Marker::bind(provider), &tz::MzSpecificShortV1Marker::bind(provider), + &tz::MzPeriodV1Marker::bind(provider), &ExternalLoaderUnstable(provider), locale, pattern @@ -1564,6 +1580,7 @@ impl TypedDateTimeNames { &tz::MzGenericShortV1Marker::bind(&crate::provider::Baked), &tz::MzSpecificLongV1Marker::bind(&crate::provider::Baked), &tz::MzSpecificShortV1Marker::bind(&crate::provider::Baked), + &tz::MzPeriodV1Marker::bind(&crate::provider::Baked), &ExternalLoaderCompiledData, locale, pattern @@ -1646,6 +1663,7 @@ impl RawDateTimeNames { mz_generic_short: >::Container::<_>::new_empty(), mz_specific_long: >::Container::<_>::new_empty(), mz_specific_short: >::Container::<_>::new_empty(), + mz_periods: >::Container::<_>::new_empty(), fixed_decimal_formatter: None, _marker: PhantomData, } @@ -1663,6 +1681,7 @@ impl RawDateTimeNames { mz_generic_short: self.mz_generic_short.get().inner, mz_specific_long: self.mz_specific_long.get().inner, mz_specific_short: self.mz_specific_short.get().inner, + mz_periods: self.mz_periods.get().inner, fixed_decimal_formatter: self.fixed_decimal_formatter.as_ref(), } } @@ -1883,14 +1902,12 @@ impl RawDateTimeNames { Ok(()) } - pub(crate) fn load_time_zone_generic_long_names

( + pub(crate) fn load_time_zone_generic_long_names( &mut self, - provider: &P, + mz_generic_long_provider: &(impl BoundDataProvider + ?Sized), + mz_period_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - ) -> Result<(), SingleLoadError> - where - P: BoundDataProvider + ?Sized, - { + ) -> Result<(), SingleLoadError> { let field = fields::Field { symbol: FieldSymbol::TimeZone(fields::TimeZone::LowerV), length: FieldLength::Wide, @@ -1901,20 +1918,22 @@ impl RawDateTimeNames { ..Default::default() }; self.mz_generic_long - .load_put(provider, req, variables) + .load_put(mz_generic_long_provider, req, variables) + .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? + .map_err(SingleLoadError::Data)?; + self.mz_periods + .load_put(mz_period_provider, Default::default(), variables) .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? .map_err(SingleLoadError::Data)?; Ok(()) } - pub(crate) fn load_time_zone_generic_short_names

( + pub(crate) fn load_time_zone_generic_short_names( &mut self, - provider: &P, + mz_generic_short_provider: &(impl BoundDataProvider + ?Sized), + mz_period_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - ) -> Result<(), SingleLoadError> - where - P: BoundDataProvider + ?Sized, - { + ) -> Result<(), SingleLoadError> { let field = fields::Field { symbol: FieldSymbol::TimeZone(fields::TimeZone::LowerV), length: FieldLength::One, @@ -1925,20 +1944,22 @@ impl RawDateTimeNames { ..Default::default() }; self.mz_generic_short - .load_put(provider, req, variables) + .load_put(mz_generic_short_provider, req, variables) + .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? + .map_err(SingleLoadError::Data)?; + self.mz_periods + .load_put(mz_period_provider, Default::default(), variables) .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? .map_err(SingleLoadError::Data)?; Ok(()) } - pub(crate) fn load_time_zone_specific_long_names

( + pub(crate) fn load_time_zone_specific_long_names( &mut self, - provider: &P, + mz_specific_long_provider: &(impl BoundDataProvider + ?Sized), + mz_period_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - ) -> Result<(), SingleLoadError> - where - P: BoundDataProvider + ?Sized, - { + ) -> Result<(), SingleLoadError> { let field = fields::Field { symbol: FieldSymbol::TimeZone(fields::TimeZone::LowerZ), length: FieldLength::Wide, @@ -1949,20 +1970,22 @@ impl RawDateTimeNames { ..Default::default() }; self.mz_specific_long - .load_put(provider, req, variables) + .load_put(mz_specific_long_provider, req, variables) + .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? + .map_err(SingleLoadError::Data)?; + self.mz_periods + .load_put(mz_period_provider, Default::default(), variables) .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? .map_err(SingleLoadError::Data)?; Ok(()) } - pub(crate) fn load_time_zone_specific_short_names

( + pub(crate) fn load_time_zone_specific_short_names( &mut self, - provider: &P, + mz_specific_short_provider: &(impl BoundDataProvider + ?Sized), + mz_period_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - ) -> Result<(), SingleLoadError> - where - P: BoundDataProvider + ?Sized, - { + ) -> Result<(), SingleLoadError> { let field = fields::Field { symbol: FieldSymbol::TimeZone(fields::TimeZone::LowerZ), length: FieldLength::One, @@ -1973,7 +1996,11 @@ impl RawDateTimeNames { ..Default::default() }; self.mz_specific_short - .load_put(provider, req, variables) + .load_put(mz_specific_short_provider, req, variables) + .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? + .map_err(SingleLoadError::Data)?; + self.mz_periods + .load_put(mz_period_provider, Default::default(), variables) .map_err(|e| MaybePayloadError2::into_single_load_error(e, field))? .map_err(SingleLoadError::Data)?; Ok(()) @@ -2024,6 +2051,7 @@ impl RawDateTimeNames { mz_generic_short_provider: &(impl BoundDataProvider + ?Sized), mz_specific_long_provider: &(impl BoundDataProvider + ?Sized), mz_specific_short_provider: &(impl BoundDataProvider + ?Sized), + mz_period_provider: &(impl BoundDataProvider + ?Sized), fixed_decimal_formatter_loader: &impl FixedDecimalFormatterLoader, locale: &DataLocale, pattern_items: impl Iterator, @@ -2059,6 +2087,7 @@ impl RawDateTimeNames { .map_err(LoadError::Data)?; self.load_time_zone_specific_short_names( mz_specific_short_provider, + mz_period_provider, locale, )?; } @@ -2072,6 +2101,7 @@ impl RawDateTimeNames { .map_err(LoadError::Data)?; self.load_time_zone_specific_long_names( mz_specific_long_provider, + mz_period_provider, locale, )?; } @@ -2085,6 +2115,7 @@ impl RawDateTimeNames { .map_err(LoadError::Data)?; self.load_time_zone_generic_short_names( mz_generic_short_provider, + mz_period_provider, locale, )?; // For fallback: @@ -2100,6 +2131,7 @@ impl RawDateTimeNames { .map_err(LoadError::Data)?; self.load_time_zone_generic_long_names( mz_generic_long_provider, + mz_period_provider, locale, )?; // For fallback: @@ -2400,10 +2432,10 @@ where where I: ?Sized + IsInCalendar - + GetField<::TimeZoneOffsetInput> + GetField<::TimeZoneIdInput> - + GetField<::TimeZoneMetazoneInput> + + GetField<::TimeZoneOffsetInput> + GetField<::TimeZoneVariantInput> + + GetField<::TimeZoneLocalTimeInput> + GetField, { FormattedDateTimePattern { @@ -2592,6 +2624,7 @@ impl<'data> RawDateTimeNamesBorrowed<'data> { mz_generic_short: self.mz_generic_short.get_option(), mz_specific_long: self.mz_specific_long.get_option(), mz_specific_short: self.mz_specific_short.get_option(), + mz_periods: self.mz_periods.get_option(), } } } diff --git a/components/datetime/src/input.rs b/components/datetime/src/input.rs index 67840ccce02..a81029c429f 100644 --- a/components/datetime/src/input.rs +++ b/components/datetime/src/input.rs @@ -6,16 +6,16 @@ //! formatting operations. use crate::neo_marker::{DateInputMarkers, GetField, TimeMarkers, ZoneMarkers}; -use crate::provider::time_zones::{MetazoneId, TimeZoneBcp47Id}; use icu_calendar::any_calendar::AnyCalendarKind; -use icu_timezone::{UtcOffset, ZoneVariant}; +use icu_calendar::{Date, Iso, Time}; +use icu_timezone::{TimeZoneBcp47Id, UtcOffset, ZoneVariant}; // TODO(#2630) fix up imports to directly import from icu_calendar pub(crate) use icu_calendar::types::{ DayOfMonth, IsoHour, IsoMinute, IsoSecond, IsoWeekday, MonthInfo, NanoSecond, YearInfo, }; -#[derive(Default, Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone)] pub(crate) struct ExtractedInput { pub(crate) year: Option, pub(crate) month: Option, @@ -26,10 +26,10 @@ pub(crate) struct ExtractedInput { pub(crate) minute: Option, pub(crate) second: Option, pub(crate) nanosecond: Option, - pub(crate) offset: Option, pub(crate) time_zone_id: Option, - pub(crate) metazone_id: Option>, + pub(crate) offset: Option, pub(crate) zone_variant: Option, + pub(crate) local_time: Option<(Date, Time)>, } impl ExtractedInput { @@ -49,10 +49,10 @@ impl ExtractedInput { + GetField + GetField + GetField - + GetField + GetField - + GetField - + GetField, + + GetField + + GetField + + GetField, { Self { year: GetField::::get_field(input).into(), @@ -64,10 +64,10 @@ impl ExtractedInput { minute: GetField::::get_field(input).into(), second: GetField::::get_field(input).into(), nanosecond: GetField::::get_field(input).into(), - offset: GetField::::get_field(input).into(), time_zone_id: GetField::::get_field(input).into(), - metazone_id: GetField::::get_field(input).into(), + offset: GetField::::get_field(input).into(), zone_variant: GetField::::get_field(input).into(), + local_time: GetField::::get_field(input).into(), } } } diff --git a/components/datetime/src/lib.rs b/components/datetime/src/lib.rs index 179793d16d7..34c5d03aff2 100644 --- a/components/datetime/src/lib.rs +++ b/components/datetime/src/lib.rs @@ -12,7 +12,7 @@ //! used to quickly format any date and time provided. There are variants of these types that can format greater or fewer components. //! //! These formatters work with types from the [`calendar`] module, like [`Date`], [`DateTime`], and [`Time`], -//! and [`timezone::CustomTimeZone`], however other types may be used provided they implement the traits from the [`input`] module. +//! and [`timezone::TimeZoneInfo`], however other types may be used provided they implement the traits from the [`input`] module. //! //! Each instance of a date-related formatter is associated with a particular [`Calendar`]. //! The "Typed" vs untyped formatter distinction is to help with this. For example, if you know at compile time that you @@ -69,7 +69,7 @@ //! [`Time`]: calendar::types::{Time} //! [`Calendar`]: calendar::{Calendar} //! [`AnyCalendar`]: calendar::any_calendar::{AnyCalendar} -//! [`timezone::CustomTimeZone`]: icu::timezone::{CustomTimeZone} +//! [`timezone::TimeZoneInfo`]: icu::timezone::{TimeZoneInfo} // https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations #![cfg_attr(not(any(test, feature = "std")), no_std)] diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index 9c4323af662..ab8cbba6cfa 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -221,6 +221,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider, { Self::try_new_internal( @@ -262,6 +263,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider // FixedDecimalFormatter markers + DataProvider, @@ -420,6 +422,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider, { Self::try_new_internal( @@ -461,6 +464,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider // FixedDecimalFormatter markers + DataProvider, @@ -503,6 +507,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider, L: FixedDecimalFormatterLoader, { @@ -535,6 +540,7 @@ where &::GenericShortV1Marker::bind(provider), &::SpecificLongV1Marker::bind(provider), &::SpecificShortV1Marker::bind(provider), + &::MetazonePeriodV1Marker::bind(provider), loader, // fixed decimal formatter locale, selection.pattern_items_for_data_loading(), @@ -753,6 +759,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider, { Self::try_new_internal( @@ -842,6 +849,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider // AnyCalendar constructor markers + DataProvider @@ -1053,6 +1061,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider { Self::try_new_internal( @@ -1142,6 +1151,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider // AnyCalendar constructor markers + DataProvider @@ -1239,6 +1249,7 @@ where + DataProvider<::GenericShortV1Marker> + DataProvider<::SpecificLongV1Marker> + DataProvider<::SpecificShortV1Marker> + + DataProvider<::MetazonePeriodV1Marker> + DataProvider, L: FixedDecimalFormatterLoader + AnyCalendarLoader, { @@ -1273,6 +1284,7 @@ where &::GenericShortV1Marker::bind(provider), &::SpecificLongV1Marker::bind(provider), &::SpecificShortV1Marker::bind(provider), + &::MetazonePeriodV1Marker::bind(provider), loader, // fixed decimal formatter locale, selection.pattern_items_for_data_loading(), diff --git a/components/datetime/src/neo_marker.rs b/components/datetime/src/neo_marker.rs index a3a88ca38d7..c0ba55803d6 100644 --- a/components/datetime/src/neo_marker.rs +++ b/components/datetime/src/neo_marker.rs @@ -266,8 +266,8 @@ //! which falls back to the offset when unavailable (see [`NeoTimeZoneGenericMarker`]). //! //! ``` -//! use icu::calendar::DateTime; -//! use icu::timezone::{CustomTimeZone, MetazoneCalculator, TimeZoneIdMapper, TimeZoneBcp47Id}; +//! use icu::calendar::{Date, Time}; +//! use icu::timezone::{TimeZoneInfo, UtcOffset, TimeZoneIdMapper, TimeZoneBcp47Id}; //! use icu::datetime::neo::TypedNeoFormatter; //! use icu::datetime::neo_marker::NeoTimeZoneGenericMarker; //! use icu::datetime::neo_skeleton::NeoSkeletonLength; @@ -279,15 +279,11 @@ //! // Set up the time zone. Note: the inputs here are //! // 1. The offset //! // 2. The IANA time zone ID -//! // 3. A datetime (for metazone resolution) +//! // 3. A date and time (for non-location name resolution) //! // 4. Note: we do not need the zone variant because of `load_generic_*()` //! -//! // Set up the Metazone calculator, time zone ID mapper, -//! // and the DateTime to use in calculation -//! let mzc = MetazoneCalculator::new(); +//! // Set up the time zone ID mapper //! let mapper = TimeZoneIdMapper::new(); -//! let datetime = DateTime::try_new_iso_datetime(2022, 8, 29, 0, 0, 0) -//! .unwrap(); //! //! // Set up the formatter //! let mut tzf = TypedNeoFormatter::<(), _>::try_new( @@ -296,40 +292,29 @@ //! ) //! .unwrap(); //! -//! // "uschi" - has metazone symbol data for generic_non_location_short -//! let mut time_zone = "-0600".parse::().unwrap(); -//! time_zone.time_zone_id = mapper.as_borrowed().iana_to_bcp47("America/Chicago"); -//! time_zone.maybe_calculate_metazone(&mzc, &datetime); +//! // "uschi" - has symbol data for generic_non_location_short +//! let time_zone = TimeZoneInfo { +//! time_zone_id: mapper.as_borrowed().iana_to_bcp47("America/Chicago"), +//! offset: Some(UtcOffset::from_eighths_of_hour(-6 * 8)), +//! local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), +//! ..TimeZoneInfo::unknown() +//! }; //! assert_try_writeable_eq!( //! tzf.format(&time_zone), //! "CT" //! ); //! //! // "ushnl" - has time zone override symbol data for generic_non_location_short -//! let mut time_zone = "-1000".parse::().unwrap(); -//! time_zone.time_zone_id = TimeZoneBcp47Id(tinystr!(8, "ushnl")); -//! time_zone.maybe_calculate_metazone(&mzc, &datetime); +//! let time_zone = TimeZoneInfo { +//! time_zone_id: TimeZoneBcp47Id(tinystr!(8, "ushnl")), +//! offset: Some(UtcOffset::from_eighths_of_hour(-10 * 8)), +//! local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), +//! ..TimeZoneInfo::unknown() +//! }; //! assert_try_writeable_eq!( //! tzf.format(&time_zone), //! "HST" //! ); -//! -//! // If we don't calculate the metazone, it falls back to generic location -//! let mut time_zone = "-1000".parse::().unwrap(); -//! time_zone.time_zone_id = TimeZoneBcp47Id(tinystr!(8, "ushnl")); -//! assert_try_writeable_eq!( -//! tzf.format(&time_zone), -//! "{v}", -//! Err(DateTimeWriteError::MissingInputField("metazone")) -//! ); -//! -//! // If we don't set a zone at all, there's no fallback to the offset -//! let mut time_zone = "+0530".parse::().unwrap(); -//! assert_try_writeable_eq!( -//! tzf.format(&time_zone), -//! "{v}", -//! Err(DateTimeWriteError::MissingInputField("metazone")) -//! ); //! ``` #[cfg(doc)] @@ -349,12 +334,10 @@ use icu_calendar::{ DayOfMonth, DayOfYearInfo, IsoHour, IsoMinute, IsoSecond, IsoWeekday, MonthInfo, NanoSecond, YearInfo, }, - AnyCalendar, AnyCalendarKind, AsCalendar, Calendar, Date, DateTime, Ref, Time, + AnyCalendar, AnyCalendarKind, AsCalendar, Calendar, Date, DateTime, Iso, Ref, Time, }; use icu_provider::{marker::NeverMarker, prelude::*}; -use icu_timezone::{ - CustomTimeZone, CustomZonedDateTime, MetazoneId, TimeZoneBcp47Id, UtcOffset, ZoneVariant, -}; +use icu_timezone::{CustomZonedDateTime, TimeZoneBcp47Id, TimeZoneInfo, UtcOffset, ZoneVariant}; /// A type that can be converted into a specific calendar system. pub trait ConvertCalendar { @@ -401,8 +384,8 @@ impl> ConvertCalendar for Custom } } -impl ConvertCalendar for CustomTimeZone { - type Converted<'a> = CustomTimeZone; +impl ConvertCalendar for TimeZoneInfo { + type Converted<'a> = TimeZoneInfo; #[inline] fn to_calendar<'a>(&self, _: &'a AnyCalendar) -> Self::Converted<'a> { *self @@ -454,7 +437,7 @@ impl> IsInCalendar for DateTime { impl> IsInCalendar for CustomZonedDateTime {} -impl IsInCalendar for CustomTimeZone {} +impl IsInCalendar for TimeZoneInfo {} /// A type that can return a certain field `T`. pub trait GetField { @@ -723,67 +706,67 @@ impl> GetField for CustomZo } } -impl> GetField> +impl> GetField for CustomZonedDateTime { #[inline] - fn get_field(&self) -> Option { - self.zone.offset + fn get_field(&self) -> TimeZoneBcp47Id { + self.zone.time_zone_id } } -impl> GetField> +impl> GetField> for CustomZonedDateTime { #[inline] - fn get_field(&self) -> Option { - Some(self.zone.time_zone_id) + fn get_field(&self) -> Option { + self.zone.offset } } -impl> GetField>> +impl> GetField> for CustomZonedDateTime { #[inline] - fn get_field(&self) -> Option> { - self.zone.metazone_id + fn get_field(&self) -> Option { + self.zone.zone_variant } } -impl> GetField> +impl> GetField, Time)>> for CustomZonedDateTime { #[inline] - fn get_field(&self) -> Option { - self.zone.zone_variant + fn get_field(&self) -> Option<(Date, Time)> { + self.zone.local_time } } -impl GetField> for CustomTimeZone { +impl GetField for TimeZoneInfo { #[inline] - fn get_field(&self) -> Option { - self.offset + fn get_field(&self) -> TimeZoneBcp47Id { + self.time_zone_id } } -impl GetField> for CustomTimeZone { +impl GetField> for TimeZoneInfo { #[inline] - fn get_field(&self) -> Option { - Some(self.time_zone_id) + fn get_field(&self) -> Option { + self.offset } } -impl GetField>> for CustomTimeZone { +impl GetField> for TimeZoneInfo { #[inline] - fn get_field(&self) -> Option> { - self.metazone_id + fn get_field(&self) -> Option { + self.zone_variant } } -impl GetField> for CustomTimeZone { +impl GetField, Time)>> for TimeZoneInfo { #[inline] - fn get_field(&self) -> Option { - self.zone_variant + fn get_field(&self) -> Option<(Date, Time)> { + self.local_time } } @@ -820,7 +803,7 @@ impl> GetField for CustomZo } } -impl GetField for CustomTimeZone { +impl GetField for TimeZoneInfo { #[inline] fn get_field(&self) -> NeverField { NeverField @@ -897,28 +880,28 @@ impl From for Option { } } -impl From for Option { +impl From for Option { #[inline] fn from(_: NeverField) -> Self { None } } -impl From for Option { +impl From for Option { #[inline] fn from(_: NeverField) -> Self { None } } -impl From for Option> { +impl From for Option { #[inline] fn from(_: NeverField) -> Self { None } } -impl From for Option { +impl From for Option<(Date, Time)> { #[inline] fn from(_: NeverField) -> Self { None @@ -1040,26 +1023,28 @@ pub trait TimeMarkers: UnstableSealed { /// A trait associating types for time zone formatting /// (input types and data markers). pub trait ZoneMarkers: UnstableSealed { - /// Marker for resolving the time zone offset input field. - type TimeZoneOffsetInput: Into>; /// Marker for resolving the time zone id input field. type TimeZoneIdInput: Into>; - /// Marker for resolving the time zone metazone input field. - type TimeZoneMetazoneInput: Into>>; + /// Marker for resolving the time zone offset input field. + type TimeZoneOffsetInput: Into>; /// Marker for resolving the time zone variant input field. type TimeZoneVariantInput: Into>; + /// Marker for resolving the time zone non-location display names, which depend on the datetime. + type TimeZoneLocalTimeInput: Into, Time)>>; /// Marker for loading core time zone data. type EssentialsV1Marker: DataMarker>; /// Marker for loading location names for time zone formatting type LocationsV1Marker: DataMarker>; - /// Marker for loading generic short time zone names. + /// Marker for loading generic long time zone names. type GenericLongV1Marker: DataMarker>; /// Marker for loading generic short time zone names. type GenericShortV1Marker: DataMarker>; - /// Marker for loading generic short time zone names. + /// Marker for loading specific long time zone names. type SpecificLongV1Marker: DataMarker>; /// Marker for loading generic short time zone names. type SpecificShortV1Marker: DataMarker>; + /// Marker for loading metazone periods. + type MetazonePeriodV1Marker: DataMarker>; } /// A trait associating constants and types implementing various other traits @@ -1100,10 +1085,10 @@ pub trait AllInputMarkers: + GetField<::MinuteInput> + GetField<::SecondInput> + GetField<::NanoSecondInput> - + GetField<::TimeZoneOffsetInput> + GetField<::TimeZoneIdInput> - + GetField<::TimeZoneMetazoneInput> + + GetField<::TimeZoneOffsetInput> + GetField<::TimeZoneVariantInput> + + GetField<::TimeZoneLocalTimeInput> where R::D: DateInputMarkers, R::T: TimeMarkers, @@ -1126,10 +1111,10 @@ where + GetField<::MinuteInput> + GetField<::SecondInput> + GetField<::NanoSecondInput> - + GetField<::TimeZoneOffsetInput> + GetField<::TimeZoneIdInput> - + GetField<::TimeZoneMetazoneInput> - + GetField<::TimeZoneVariantInput>, + + GetField<::TimeZoneOffsetInput> + + GetField<::TimeZoneVariantInput> + + GetField<::TimeZoneLocalTimeInput>, { } @@ -1172,16 +1157,17 @@ impl TimeMarkers for NeoNeverMarker { } impl ZoneMarkers for NeoNeverMarker { - type TimeZoneOffsetInput = NeverField; type TimeZoneIdInput = NeverField; - type TimeZoneMetazoneInput = NeverField; + type TimeZoneOffsetInput = NeverField; type TimeZoneVariantInput = NeverField; + type TimeZoneLocalTimeInput = NeverField; type EssentialsV1Marker = NeverMarker>; type LocationsV1Marker = NeverMarker>; type GenericLongV1Marker = NeverMarker>; type GenericShortV1Marker = NeverMarker>; type SpecificLongV1Marker = NeverMarker>; type SpecificShortV1Marker = NeverMarker>; + type MetazonePeriodV1Marker = NeverMarker>; } /// A struct that supports formatting both a date and a time. @@ -1240,6 +1226,7 @@ where type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } impl HasConstComponents for DateTimeCombo @@ -1277,6 +1264,7 @@ where type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } impl HasConstComponents for DateTimeCombo @@ -1314,6 +1302,7 @@ where type ZoneGenericShort = Z::ZoneGenericShort; type ZoneSpecificLong = Z::ZoneSpecificLong; type ZoneSpecificShort = Z::ZoneSpecificShort; + type MetazoneLookup = Z::MetazoneLookup; } impl HasConstComponents for DateTimeCombo @@ -1352,6 +1341,7 @@ where type ZoneGenericShort = NeverMarker<()>; type ZoneSpecificLong = NeverMarker<()>; type ZoneSpecificShort = NeverMarker<()>; + type MetazoneLookup = NeverMarker<()>; } impl HasConstComponents for DateTimeCombo @@ -1393,6 +1383,7 @@ where type ZoneGenericShort = Z::ZoneGenericShort; type ZoneSpecificLong = Z::ZoneSpecificLong; type ZoneSpecificShort = Z::ZoneSpecificShort; + type MetazoneLookup = Z::MetazoneLookup; } impl HasConstComponents for DateTimeCombo @@ -1526,18 +1517,18 @@ macro_rules! datetime_marker_helper { (@input/nanosecond, yes) => { NanoSecond }; - (@input/timezone/offset, yes) => { - Option - }; (@input/timezone/id, yes) => { - Option + TimeZoneBcp47Id }; - (@input/timezone/metazone, yes) => { - Option> + (@input/timezone/offset, yes) => { + Option }; (@input/timezone/variant, yes) => { Option }; + (@input/timezone/local_time, yes) => { + Option<(Date, Time)> + }; (@input/$any:ident,) => { NeverField }; @@ -1559,6 +1550,9 @@ macro_rules! datetime_marker_helper { (@data/zone/specific_short, yes) => { tz::MzSpecificShortV1Marker }; + (@data/zone/metazone_periods, yes) => { + tz::MzPeriodV1Marker + }; (@data/zone/essentials,) => { NeverMarker> }; @@ -1577,6 +1571,9 @@ macro_rules! datetime_marker_helper { (@data/zone/specific_short,) => { NeverMarker> }; + (@data/zone/metazone_periods,) => { + NeverMarker> + }; (@names/year, yes) => { YearNamesV1Marker }; @@ -1607,6 +1604,9 @@ macro_rules! datetime_marker_helper { (@names/zone/specific_short, yes) => { tz::MzSpecificShortV1Marker }; + (@names/zone/metazone_periods, yes) => { + tz::MzPeriodV1Marker + }; (@names/$any:ident,) => { NeverMarker<()> }; @@ -1833,6 +1833,7 @@ macro_rules! impl_date_or_calendar_period_marker { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl DateInputMarkers for $type { type YearInput = datetime_marker_helper!(@input/year, $($year_yes)?); @@ -2057,6 +2058,7 @@ macro_rules! impl_time_marker { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl HasConstTimeComponents for $type { const COMPONENTS: NeoTimeComponents = $components; @@ -2117,6 +2119,8 @@ macro_rules! impl_zone_marker { $(zone_specific_long = $zone_specific_long_yes:ident,)? // Whether specific short formats can occur. $(zone_specific_short = $zone_specific_short_yes:ident,)? + // Whether metazone periods are needed + $(metazone_periods = $metazone_periods_yes:ident,)? ) => { impl_marker_with_options!( #[doc = concat!("**“", $sample, "**” ⇒ ", $description)] @@ -2126,7 +2130,8 @@ macro_rules! impl_zone_marker { /// In [`NeoFormatter`](crate::neo::NeoFormatter): /// /// ``` - /// use icu::timezone::CustomTimeZone; + /// use icu::calendar::{Date, Time}; + /// use icu::timezone::{TimeZoneBcp47Id, TimeZoneInfo, UtcOffset, ZoneVariant}; /// use icu::datetime::neo::NeoFormatter; #[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")] /// use icu::datetime::neo_skeleton::NeoSkeletonLength; @@ -2140,13 +2145,13 @@ macro_rules! impl_zone_marker { /// ) /// .unwrap(); /// - /// // Time zone for America/Chicago in the summer - /// let zone = CustomTimeZone::from_parts( - /// -40, // offset eighths of hour - /// tinystr!(8, "uschi"), // time zone ID - /// tinystr!(4, "amce"), // metazone ID - /// tinystr!(2, "dt"), // zone variant: daylight time - /// ); + /// // Time zone info for America/Chicago in the summer + /// let zone = TimeZoneInfo { + /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), + /// offset: Some(UtcOffset::from_eighths_of_hour(-5 * 8)), + /// zone_variant: Some(ZoneVariant::daylight()), + /// local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), + /// }; /// /// assert_try_writeable_eq!( /// fmt.convert_and_format(&zone), @@ -2158,7 +2163,7 @@ macro_rules! impl_zone_marker { /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{CustomZonedDateTime, TimeZoneBcp47Id, TimeZoneInfo, UtcOffset, ZoneVariant}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::TypedNeoFormatter; #[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")] @@ -2173,13 +2178,13 @@ macro_rules! impl_zone_marker { /// ) /// .unwrap(); /// - /// // Time zone for America/Chicago in the summer - /// let zone = CustomTimeZone::from_parts( - /// -40, // offset eighths of hour - /// tinystr!(8, "uschi"), // time zone ID - /// tinystr!(4, "amce"), // metazone ID - /// tinystr!(2, "dt"), // zone variant: daylight time - /// ); + /// // Time zone info for America/Chicago in the summer + /// let zone = TimeZoneInfo { + /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), + /// offset: Some(UtcOffset::from_eighths_of_hour(-5 * 8)), + /// zone_variant: Some(ZoneVariant::daylight()), + /// local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), + /// }; /// /// assert_try_writeable_eq!( /// fmt.format(&zone), @@ -2202,21 +2207,23 @@ macro_rules! impl_zone_marker { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, $($zone_generic_short_yes)?); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, $($zone_specific_long_yes)?); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, $($zone_specific_short_yes)?); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods, $($metazone_periods_yes)?); } impl HasConstZoneComponent for $type { const COMPONENT: NeoTimeZoneStyle = $components; } impl ZoneMarkers for $type { - type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes); type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, yes); - type TimeZoneMetazoneInput = datetime_marker_helper!(@input/timezone/metazone, yes); + type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes); type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, yes); + type TimeZoneLocalTimeInput = datetime_marker_helper!(@input/timezone/local_time, yes); type EssentialsV1Marker = datetime_marker_helper!(@data/zone/essentials, $($zone_essentials_yes)?); type LocationsV1Marker = datetime_marker_helper!(@data/zone/locations, $($zone_locations_yes)?); type GenericLongV1Marker = datetime_marker_helper!(@data/zone/generic_long, $($zone_generic_long_yes)?); type GenericShortV1Marker = datetime_marker_helper!(@data/zone/generic_short, $($zone_generic_short_yes)?); type SpecificLongV1Marker = datetime_marker_helper!(@data/zone/specific_long, $($zone_specific_long_yes)?); type SpecificShortV1Marker = datetime_marker_helper!(@data/zone/specific_short, $($zone_specific_short_yes)?); + type MetazonePeriodV1Marker = datetime_marker_helper!(@data/zone/metazone_periods, $($metazone_periods_yes)?); } impl DateTimeMarkers for $type { type D = NeoNeverMarker; @@ -2315,7 +2322,7 @@ macro_rules! impl_zoneddatetime_marker { /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime}; /// use icu::datetime::neo::NeoFormatter; #[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")] /// use icu::datetime::neo_skeleton::NeoSkeletonLength; @@ -2340,7 +2347,7 @@ macro_rules! impl_zoneddatetime_marker { /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::TypedNeoFormatter; #[doc = concat!("use icu::datetime::neo_marker::", stringify!($type), ";")] @@ -2490,7 +2497,7 @@ impl_zone_marker!( /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{CustomZonedDateTime, TimeZoneBcp47Id, TimeZoneInfo, UtcOffset, ZoneVariant}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::TypedNeoFormatter; /// use icu::datetime::neo_marker::NeoTimeZoneSpecificMarker; @@ -2505,13 +2512,13 @@ impl_zone_marker!( /// ) /// .unwrap(); /// - /// // Time zone for America/Sao_Paulo year-round - /// let zone = CustomTimeZone::from_parts( - /// -24, // offset eighths of hour - /// tinystr!(8, "brsao"), // time zone ID - /// tinystr!(4, "bras"), // metazone ID - /// tinystr!(2, "st"), // zone variant: standard time - /// ); + /// // Time zone info for America/Sao_Paulo in the summer + /// let zone = TimeZoneInfo { + /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "brsao")), + /// offset: Some(UtcOffset::from_eighths_of_hour(-3 * 8)), + /// zone_variant: Some(ZoneVariant::standard()), + /// local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), + /// }; /// /// assert_try_writeable_eq!( /// fmt.format(&zone), @@ -2526,6 +2533,7 @@ impl_zone_marker!( zone_essentials = yes, zone_specific_long = yes, zone_specific_short = yes, + metazone_periods = yes, ); impl_zone_marker!( @@ -2533,7 +2541,7 @@ impl_zone_marker!( /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::NeoFormatter; /// use icu::datetime::neo_marker::NeoMonthDayMarker; @@ -2589,6 +2597,7 @@ impl_zone_marker!( sample = "CDT", zone_essentials = yes, zone_specific_short = yes, + metazone_periods = yes, ); impl_zone_marker!( @@ -2605,7 +2614,7 @@ impl_zone_marker!( /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{CustomZonedDateTime, TimeZoneBcp47Id, TimeZoneInfo, UtcOffset, ZoneVariant}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::TypedNeoFormatter; /// use icu::datetime::neo_marker::NeoTimeZoneGenericMarker; @@ -2620,13 +2629,13 @@ impl_zone_marker!( /// ) /// .unwrap(); /// - /// // Time zone for America/Sao_Paulo year-round - /// let zone = CustomTimeZone::from_parts( - /// -24, // offset eighths of hour - /// tinystr!(8, "brsao"), // time zone ID - /// tinystr!(4, "bras"), // metazone ID - /// tinystr!(2, "st"), // zone variant: standard time - /// ); + /// // Time zone info for America/Sao_Paulo in the summer + /// let zone = TimeZoneInfo { + /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "brsao")), + /// offset: Some(UtcOffset::from_eighths_of_hour(-3 * 8)), + /// zone_variant: Some(ZoneVariant::standard()), + /// local_time: Some((Date::try_new_iso_date(2022, 8, 29).unwrap(), Time::midnight())), + /// }; /// /// assert_try_writeable_eq!( /// fmt.format(&zone), @@ -2642,6 +2651,7 @@ impl_zone_marker!( zone_locations = yes, zone_generic_long = yes, zone_generic_short = yes, + metazone_periods = yes, ); impl_zone_marker!( @@ -2649,7 +2659,7 @@ impl_zone_marker!( /// /// ``` /// use icu::calendar::{Date, Time}; - /// use icu::timezone::{CustomTimeZone, CustomZonedDateTime}; + /// use icu::timezone::{TimeZoneInfo, CustomZonedDateTime}; /// use icu::calendar::Gregorian; /// use icu::datetime::neo::NeoFormatter; /// use icu::datetime::neo_marker::NeoMonthDayMarker; @@ -2706,6 +2716,7 @@ impl_zone_marker!( zone_essentials = yes, zone_locations = yes, zone_generic_short = yes, + metazone_periods = yes, ); impl_zone_marker!( @@ -2753,6 +2764,7 @@ impl DateTimeNamesMarker for NeoDateSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl DateInputMarkers for NeoDateSkeleton { @@ -2814,6 +2826,7 @@ impl DateTimeNamesMarker for NeoCalendarPeriodSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl DateInputMarkers for NeoCalendarPeriodSkeleton { @@ -2875,6 +2888,7 @@ impl DateTimeNamesMarker for NeoTimeSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl TimeMarkers for NeoTimeSkeleton { @@ -2923,19 +2937,21 @@ impl DateTimeNamesMarker for NeoTimeZoneSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, yes); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, yes); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, yes); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods, yes); } impl ZoneMarkers for NeoTimeZoneSkeleton { - type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes); type TimeZoneIdInput = datetime_marker_helper!(@input/timezone/id, yes); - type TimeZoneMetazoneInput = datetime_marker_helper!(@input/timezone/metazone, yes); + type TimeZoneOffsetInput = datetime_marker_helper!(@input/timezone/offset, yes); type TimeZoneVariantInput = datetime_marker_helper!(@input/timezone/variant, yes); + type TimeZoneLocalTimeInput = datetime_marker_helper!(@input/timezone/local_time, yes); type EssentialsV1Marker = datetime_marker_helper!(@data/zone/essentials, yes); type LocationsV1Marker = datetime_marker_helper!(@data/zone/locations, yes); type GenericLongV1Marker = datetime_marker_helper!(@data/zone/generic_long, yes); type GenericShortV1Marker = datetime_marker_helper!(@data/zone/generic_short, yes); type SpecificLongV1Marker = datetime_marker_helper!(@data/zone/specific_long, yes); type SpecificShortV1Marker = datetime_marker_helper!(@data/zone/specific_short, yes); + type MetazonePeriodV1Marker = datetime_marker_helper!(@data/zone/metazone_periods, yes); } impl DateTimeMarkers for NeoTimeZoneSkeleton { @@ -2973,6 +2989,7 @@ impl DateTimeNamesMarker for NeoDateTimeSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short,); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long,); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short,); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods,); } impl DateTimeMarkers for NeoDateTimeSkeleton { @@ -3013,6 +3030,7 @@ impl DateTimeNamesMarker for NeoSkeleton { type ZoneGenericShort = datetime_marker_helper!(@names/zone/generic_short, yes); type ZoneSpecificLong = datetime_marker_helper!(@names/zone/specific_long, yes); type ZoneSpecificShort = datetime_marker_helper!(@names/zone/specific_short, yes); + type MetazoneLookup = datetime_marker_helper!(@names/zone/metazone_periods, yes); } impl DateTimeMarkers for NeoSkeleton { diff --git a/components/datetime/src/provider/mod.rs b/components/datetime/src/provider/mod.rs index 1c5bc01c075..dfd055ebd5c 100644 --- a/components/datetime/src/provider/mod.rs +++ b/components/datetime/src/provider/mod.rs @@ -49,6 +49,7 @@ const _: () = { impl_locations_v1_marker!(Baked); impl_metazone_generic_names_long_v1_marker!(Baked); impl_metazone_generic_names_short_v1_marker!(Baked); + impl_metazone_period_v1_marker!(Baked); impl_metazone_specific_names_long_v1_marker!(Baked); impl_metazone_specific_names_short_v1_marker!(Baked); impl_time_zone_essentials_v1_marker!(Baked); @@ -110,6 +111,7 @@ pub const MARKERS: &[DataMarkerInfo] = &[ time_zones::LocationsV1Marker::INFO, time_zones::MetazoneGenericNamesLongV1Marker::INFO, time_zones::MetazoneGenericNamesShortV1Marker::INFO, + time_zones::MetazonePeriodV1Marker::INFO, time_zones::MetazoneSpecificNamesLongV1Marker::INFO, time_zones::MetazoneSpecificNamesShortV1Marker::INFO, time_zones::TimeZoneEssentialsV1Marker::INFO, diff --git a/components/datetime/src/provider/time_zones.rs b/components/datetime/src/provider/time_zones.rs index c438aa74e37..df527229395 100644 --- a/components/datetime/src/provider/time_zones.rs +++ b/components/datetime/src/provider/time_zones.rs @@ -7,10 +7,13 @@ use alloc::borrow::Cow; use icu_pattern::{DoublePlaceholderPattern, SinglePlaceholderPattern}; use icu_provider::prelude::*; -use zerovec::{ZeroMap, ZeroMap2d}; +use tinystr::TinyAsciiStr; +use zerovec::{ + ule::{AsULE, ULE}, + ZeroMap, ZeroMap2d, ZeroSlice, ZeroVec, +}; -pub use icu_timezone::provider::{MetazoneId, TimeZoneBcp47Id}; -use icu_timezone::ZoneVariant; +use icu_timezone::{provider::IsoMinutesSinceEpoch, TimeZoneBcp47Id, ZoneVariant}; /// Time zone type aliases for cleaner code pub(crate) mod tz { @@ -19,6 +22,8 @@ pub(crate) mod tz { pub(crate) use super::MetazoneGenericNamesLongV1Marker as MzGenericLongV1Marker; pub(crate) use super::MetazoneGenericNamesShortV1Marker as MzGenericShortV1Marker; pub(crate) use super::MetazoneGenericNamesV1 as MzGenericV1; + pub(crate) use super::MetazonePeriodV1 as MzPeriodV1; + pub(crate) use super::MetazonePeriodV1Marker as MzPeriodV1Marker; pub(crate) use super::MetazoneSpecificNamesLongV1Marker as MzSpecificLongV1Marker; pub(crate) use super::MetazoneSpecificNamesShortV1Marker as MzSpecificShortV1Marker; pub(crate) use super::MetazoneSpecificNamesV1 as MzSpecificV1; @@ -170,3 +175,63 @@ pub struct MetazoneSpecificNamesV1<'data> { #[cfg_attr(feature = "serde", serde(borrow))] pub overrides: ZeroMap2d<'data, TimeZoneBcp47Id, ZoneVariant, str>, } + +/// Metazone ID in a compact format +/// +///

+#[repr(transparent)] +#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd, yoke::Yokeable, ULE, Hash)] +#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))] +#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +pub struct MetazoneId(pub TinyAsciiStr<4>); + +impl AsULE for MetazoneId { + type ULE = Self; + + #[inline] + fn to_unaligned(self) -> Self::ULE { + self + } + + #[inline] + fn from_unaligned(unaligned: Self::ULE) -> Self { + unaligned + } +} + +impl<'a> zerovec::maps::ZeroMapKV<'a> for MetazoneId { + type Container = ZeroVec<'a, MetazoneId>; + type Slice = ZeroSlice; + type GetType = MetazoneId; + type OwnedType = MetazoneId; +} + +/// An ICU4X mapping to the metazones at a given period. +/// See CLDR-JSON metaZones.json for more context. +/// +///
+/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, +/// including in SemVer minor releases. While the serde representation of data structs is guaranteed +/// to be stable, their Rust representation might not be. Use with caution. +///
+#[icu_provider::data_struct(marker( + MetazonePeriodV1Marker, + "time_zone/metazone_period@1", + singleton +))] +#[derive(PartialEq, Debug, Clone, Default)] +#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))] +#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::time_zones))] +#[cfg_attr(feature = "serde", derive(serde::Deserialize))] +#[yoke(prove_covariance_manually)] +pub struct MetazonePeriodV1<'data>( + /// The default mapping between period and metazone id. The second level key is a wall-clock time represented as + /// the number of minutes since the local unix epoch. It represents when the metazone started to be used. + #[cfg_attr(feature = "serde", serde(borrow))] + pub ZeroMap2d<'data, TimeZoneBcp47Id, IsoMinutesSinceEpoch, Option>, +); diff --git a/components/datetime/src/time_zone.rs b/components/datetime/src/time_zone.rs index 27f771e8c73..fa7de4532b4 100644 --- a/components/datetime/src/time_zone.rs +++ b/components/datetime/src/time_zone.rs @@ -4,6 +4,7 @@ //! A formatter specifically for the time zone. +use crate::provider::time_zones::MetazoneId; use crate::{ fields::{FieldLength, TimeZone}, input::ExtractedInput, @@ -11,9 +12,9 @@ use crate::{ }; use core::fmt; use fixed_decimal::FixedDecimal; +use icu_calendar::{Date, Iso, Time}; use icu_decimal::FixedDecimalFormatter; -use icu_timezone::ZoneVariant; -use icu_timezone::{TimeZoneBcp47Id, UtcOffset}; +use icu_timezone::{TimeZoneBcp47Id, UtcOffset, ZoneVariant}; use writeable::Writeable; /// All time zone styles that this crate can format @@ -212,6 +213,28 @@ pub(crate) struct TimeZoneDataPayloadsBorrowed<'a> { pub(crate) mz_specific_long: Option<&'a provider::time_zones::MetazoneSpecificNamesV1<'a>>, /// The specific short metazone names, e.g. Pacific Daylight Time pub(crate) mz_specific_short: Option<&'a provider::time_zones::MetazoneSpecificNamesV1<'a>>, + /// The metazone lookup + pub(crate) mz_periods: Option<&'a provider::time_zones::MetazonePeriodV1<'a>>, +} + +fn metazone( + time_zone_id: TimeZoneBcp47Id, + (date, time): (Date, Time), + metazone_period: &crate::provider::time_zones::MetazonePeriodV1, +) -> Option { + let cursor = metazone_period.0.get0(&time_zone_id)?; + let mut metazone_id = None; + let minutes_since_local_unix_epoch = + icu_calendar::DateTime { date, time }.minutes_since_local_unix_epoch(); + for (minutes, id) in cursor.iter1() { + if minutes_since_local_unix_epoch >= ::from_unaligned(*minutes) + { + metazone_id = id.get() + } else { + break; + } + } + metazone_id } /// Determines which ISO-8601 format should be used to format the timezone offset. @@ -340,20 +363,23 @@ impl FormatTimeZone for GenericNonLocationFormat { data_payloads: TimeZoneDataPayloadsBorrowed, _fdf: Option<&FixedDecimalFormatter>, ) -> Result, fmt::Error> { - let Some(metazone_id) = input.metazone_id else { - return Ok(Err(FormatTimeZoneError::MissingInputField("metazone"))); - }; let Some(time_zone_id) = input.time_zone_id else { return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); }; + let Some(local_time) = input.local_time else { + return Ok(Err(FormatTimeZoneError::MissingInputField("local_time"))); + }; let Some(names) = (match self.0 { FieldLength::Wide => data_payloads.mz_generic_long.as_ref(), _ => data_payloads.mz_generic_short.as_ref(), }) else { return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); }; + let Some(metazone_period) = data_payloads.mz_periods else { + return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); + }; - let Some(name) = metazone_id.and_then(|mz| { + let Some(name) = metazone(time_zone_id, local_time, metazone_period).and_then(|mz| { names .overrides .get(&time_zone_id) @@ -381,23 +407,27 @@ impl FormatTimeZone for SpecificNonLocationFormat { data_payloads: TimeZoneDataPayloadsBorrowed, _fdf: Option<&FixedDecimalFormatter>, ) -> Result, fmt::Error> { - let Some(zone_variant) = input.zone_variant else { - return Ok(Err(FormatTimeZoneError::MissingInputField("zone_offset"))); - }; - let Some(metazone_id) = input.metazone_id else { - return Ok(Err(FormatTimeZoneError::MissingInputField("metazone"))); - }; let Some(time_zone_id) = input.time_zone_id else { return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); }; + let Some(zone_variant) = input.zone_variant else { + return Ok(Err(FormatTimeZoneError::MissingInputField("zone_variant"))); + }; + let Some(local_time) = input.local_time else { + return Ok(Err(FormatTimeZoneError::MissingInputField("local_time"))); + }; + let Some(names) = (match self.0 { FieldLength::Wide => data_payloads.mz_specific_long.as_ref(), _ => data_payloads.mz_specific_short.as_ref(), }) else { return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); }; + let Some(metazone_period) = data_payloads.mz_periods else { + return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); + }; - let Some(name) = metazone_id.and_then(|mz| { + let Some(name) = metazone(time_zone_id, local_time, metazone_period).and_then(|mz| { names .overrides .get_2d(&time_zone_id, &zone_variant) @@ -516,9 +546,9 @@ impl FormatTimeZone for GenericLocationFormat { data_payloads: TimeZoneDataPayloadsBorrowed, _fdf: Option<&FixedDecimalFormatter>, ) -> Result, fmt::Error> { - let time_zone_id = input - .time_zone_id - .unwrap_or(TimeZoneBcp47Id(tinystr::tinystr!(8, "unk"))); + let Some(time_zone_id) = input.time_zone_id else { + return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); + }; let Some(locations) = data_payloads.locations else { return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); @@ -551,12 +581,12 @@ impl FormatTimeZone for SpecificLocationFormat { data_payloads: TimeZoneDataPayloadsBorrowed, _fdf: Option<&FixedDecimalFormatter>, ) -> Result, fmt::Error> { - let Some(zone_variant) = input.zone_variant else { - return Ok(Err(FormatTimeZoneError::MissingInputField("zone_offset"))); - }; let Some(time_zone_id) = input.time_zone_id else { return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); }; + let Some(zone_variant) = input.zone_variant else { + return Ok(Err(FormatTimeZoneError::MissingInputField("zone_variant"))); + }; let Some(locations) = data_payloads.locations else { return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); }; @@ -595,8 +625,8 @@ impl FormatTimeZone for GenericPartialLocationFormat { let Some(time_zone_id) = input.time_zone_id else { return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); }; - let Some(metazone_id) = input.metazone_id else { - return Ok(Err(FormatTimeZoneError::MissingInputField("metazone"))); + let Some(local_time) = input.local_time else { + return Ok(Err(FormatTimeZoneError::MissingInputField("local_time"))); }; let Some(locations) = data_payloads.locations else { @@ -608,16 +638,20 @@ impl FormatTimeZone for GenericPartialLocationFormat { }) else { return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); }; - + let Some(metazone_period) = data_payloads.mz_periods else { + return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); + }; let Some(location) = locations.locations.get(&time_zone_id) else { return Ok(Err(FormatTimeZoneError::Fallback)); }; - let Some(non_location) = metazone_id.and_then(|mz| { - non_locations - .overrides - .get(&time_zone_id) - .or_else(|| non_locations.defaults.get(&mz)) - }) else { + let Some(non_location) = + metazone(time_zone_id, local_time, metazone_period).and_then(|mz| { + non_locations + .overrides + .get(&time_zone_id) + .or_else(|| non_locations.defaults.get(&mz)) + }) + else { return Ok(Err(FormatTimeZoneError::Fallback)); }; diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index 705e90ba44a..aa976db2e42 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -38,7 +38,7 @@ use icu_locale_core::{ locale, LanguageIdentifier, Locale, }; use icu_provider::prelude::*; -use icu_timezone::{CustomTimeZone, CustomZonedDateTime, UtcOffset}; +use icu_timezone::{CustomZonedDateTime, TimeZoneIdMapper, TimeZoneInfo, UtcOffset}; use patterns::{ dayperiods::{DayPeriodExpectation, DayPeriodTests}, time_zones::{TimeZoneExpectation, TimeZoneFormatterConfig, TimeZoneTests}, @@ -281,23 +281,23 @@ fn assert_fixture_element
( let input_value = CustomZonedDateTime { date: input_value.date.clone(), time: input_value.time, - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), }; let input_iso = CustomZonedDateTime { date: input_iso.date, time: input_iso.time, - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), }; let any_input = CustomZonedDateTime { date: input_value.date.to_any(), time: input_value.time, - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), }; let iso_any_input = CustomZonedDateTime { date: input_iso.date.to_any(), time: input_iso.time, - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), }; let dtf = @@ -473,7 +473,10 @@ fn test_time_zone_format_configs() { fn test_time_zone_format_offset_seconds() { use icu_datetime::{neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength}; - let time_zone = CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(12).unwrap()); + let time_zone = TimeZoneInfo { + offset: UtcOffset::try_from_seconds(12).ok(), + ..TimeZoneInfo::unknown() + }; let tzf = TypedNeoFormatter::<(), _>::try_new( &locale!("en").into(), NeoTimeZoneOffsetMarker::with_length(NeoSkeletonLength::Medium), @@ -488,7 +491,12 @@ fn test_time_zone_format_offset_not_set_debug_assert_panic() { neo_marker::NeoTimeZoneOffsetMarker, neo_skeleton::NeoSkeletonLength, DateTimeWriteError, }; - let time_zone = CustomTimeZone::from_str("America/Los_Angeles"); + let time_zone = TimeZoneInfo { + time_zone_id: TimeZoneIdMapper::new() + .as_borrowed() + .iana_to_bcp47("America/Los_Angeles"), + ..TimeZoneInfo::unknown() + }; let tzf = TypedNeoFormatter::<(), _>::try_new( &locale!("en").into(), NeoTimeZoneOffsetMarker::with_length(NeoSkeletonLength::Medium), diff --git a/components/datetime/tests/mock.rs b/components/datetime/tests/mock.rs index 52d42c24e12..e321184fd94 100644 --- a/components/datetime/tests/mock.rs +++ b/components/datetime/tests/mock.rs @@ -37,7 +37,7 @@ pub fn parse_gregorian_from_str(input: &str) -> DateTime { datetime_iso.to_calendar(Gregorian) } -/// Parse a [`DateTime`] and [`CustomTimeZone`] from a string. +/// Parse a [`DateTime`] and [`TimeZoneInfo`] from a string. /// /// This utility is for easily creating dates, not a complete robust solution. The /// string must take a specific form of the ISO 8601 format: diff --git a/components/datetime/tests/simple_test.rs b/components/datetime/tests/simple_test.rs index 5a6ffaa3ffa..c1da8c7c13f 100644 --- a/components/datetime/tests/simple_test.rs +++ b/components/datetime/tests/simple_test.rs @@ -12,7 +12,7 @@ use icu_datetime::neo_skeleton::{ }; use icu_datetime::options::length; use icu_locale_core::{locale, Locale}; -use icu_timezone::{CustomTimeZone, CustomZonedDateTime}; +use icu_timezone::{CustomZonedDateTime, TimeZoneInfo}; use writeable::assert_try_writeable_eq; const EXPECTED_DATETIME: &[&str] = &[ @@ -140,7 +140,7 @@ fn overlap_patterns() { let datetime = CustomZonedDateTime { date: Date::try_new_gregorian_date(2024, 8, 9).unwrap(), time: Time::try_new(20, 40, 7, 250).unwrap(), - zone: CustomTimeZone::utc(), + zone: TimeZoneInfo::utc(), }; struct TestCase { locale: Locale, diff --git a/components/icu/examples/tui.rs b/components/icu/examples/tui.rs index bca8278ca6a..a2547bfdcd5 100644 --- a/components/icu/examples/tui.rs +++ b/components/icu/examples/tui.rs @@ -8,7 +8,7 @@ use icu::calendar::{Date, Gregorian, Time}; use icu::locale::locale; use icu::plurals::{PluralCategory, PluralRules}; -use icu::timezone::CustomTimeZone; +use icu::timezone::TimeZoneInfo; use icu_collections::codepointinvlist::CodePointInversionListBuilder; use icu_datetime::neo::TypedNeoFormatter; use icu_datetime::neo_marker::NeoYearMonthDayHourMinuteSecondTimeZoneGenericShortMarker; @@ -52,7 +52,7 @@ fn main() { .expect("Failed to create zoned datetime formatter."); let date = Date::try_new_gregorian_date(2020, 10, 10).unwrap(); let time = Time::try_new(18, 56, 0, 0).unwrap(); - let zone = CustomTimeZone::utc(); + let zone = TimeZoneInfo::utc(); let formatted_dt = dtf.format(&CustomZonedDateTime { date, time, zone }); diff --git a/components/timezone/README.md b/components/timezone/README.md index 322ad9a8617..5180f49bc6d 100644 --- a/components/timezone/README.md +++ b/components/timezone/README.md @@ -6,20 +6,12 @@ Types for resolving and manipulating time zones. ## Fields -In ICU4X, a [formattable time zone](CustomTimeZone) consists of four different fields: +In ICU4X, a [formattable time zone](TimeZoneInfo) consists of four different fields: -1. The offset from UTC -2. The time zone ID -3. The metazone ID -4. The zone variant, representing concepts such as Standard, Summer, Daylight, and Ramadan time - -### UTC Offset - -The UTC offset precisely states the time difference between the time zone in question and -Coordinated Universal Time (UTC). - -In localized strings, it is often rendered as "UTC-6", meaning 6 hours less than UTC (some locales -use the term "GMT" instead of "UTC"). +1. The time zone ID +2. The offset from UTC +3. The zone variant, representing concepts such as Standard, Summer, Daylight, and Ramadan time +4. A timestamp, as time zone names can change over time ### Time Zone @@ -34,31 +26,17 @@ There are two mostly-interchangeable standards for time zone IDs: ICU4X uses BCP-47 time zone IDs for all of its APIs. To get a BCP-47 time zone from an IANA time zone, use [`TimeZoneIdMapper`]. -### Metazone - -A metazone is a collection of multiple time zones that share the same localized formatting -at a particular date and time. - -For example, "America/Chicago" and "America/Indiana/Knox" both map to US Central Time, or -`"America_Central"`. - -The mapping from time zone to metazone depends on the date. For example, from 1991 to 2006, -"America/Indiana/Knox" mapped to US Eastern Time instead of US Central Time. - -As with time zone IDs, there are two interchangeable forms: - -1. Long form, like `"America_Central"` -2. Short form compatible with BCP-47, like `"amce"` +### UTC Offset -ICU4X uses the short form. +The UTC offset precisely states the time difference between the time zone in question and +Coordinated Universal Time (UTC). -Note: in ICU4X, "metazone" is one word and "time zone" is two words, except for this crate -and module name, where "timezone" is used with no separators. See -. +In localized strings, it is often rendered as "UTC-6", meaning 6 hours less than UTC (some locales +use the term "GMT" instead of "UTC"). ### Zone Variant -Many metazones use different names and offsets in the summer than in the winter. In ICU4X, +Many zones use different names and offsets in the summer than in the winter. In ICU4X, this is called the _zone variant_. CLDR has two zone variants, named `"standard"` and `"daylight"`. However, the mapping of these @@ -66,48 +44,29 @@ variants to specific observed offsets varies from time zone to time zone, and th consistently represent winter versus summer time. Note: It is optional (not required) to set the zone variant when constructing a -[`CustomTimeZone`]. Therefore, the list of possible variants does not include a generic variant +[`TimeZoneInfo`]. Therefore, the list of possible variants does not include a generic variant to represent the lack of a preference. -## Calculations - -In date/time processing, normally only a subset of information is available, and the other -fields must be computed from it. - -The following calculations are currently supported or will be supported: - -1. Time Zone + Local DateTime → Metazone ([`MetazoneCalculator`]) -2. Time Zone + Local DateTime + Offset → Zone Variant ([`ZoneOffsetCalculator`]) - ## Examples -Create a time zone for which the offset and time zone ID are already known, and calculate -the metazone based on a certain local datetime: - ```rust use icu::calendar::DateTime; -use icu::timezone::CustomTimeZone; +use icu::timezone::TimeZoneInfo; use icu::timezone::UtcOffset; -use icu::timezone::MetazoneCalculator; use icu::timezone::TimeZoneBcp47Id; use icu::timezone::TimeZoneIdMapper; use tinystr::{tinystr, TinyAsciiStr}; -// Create a time zone for America/Chicago at UTC-6: -let mut time_zone = CustomTimeZone::new_with_offset("-0600".parse().unwrap()); let mapper = TimeZoneIdMapper::new(); -time_zone.time_zone_id = - mapper.as_borrowed().iana_to_bcp47("America/Chicago"); +// Create a time zone for America/Chicago at UTC-6: +let mut time_zone = TimeZoneInfo { + time_zone_id: mapper.as_borrowed().iana_to_bcp47("America/Chicago"), + offset: Some("-0600".parse().unwrap()), + ..TimeZoneInfo::unknown() +}; // Alternatively, set it directly from the BCP-47 ID assert_eq!(time_zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); - -// Compute the metazone at January 1, 2022: -let mzc = MetazoneCalculator::new(); -let datetime = DateTime::try_new_iso_datetime(2022, 1, 1, 0, 0, 0).unwrap(); -time_zone.maybe_calculate_metazone(&mzc, &datetime); - -assert_eq!("amce", time_zone.metazone_id.unwrap().unwrap().0.as_str()); ``` diff --git a/components/timezone/src/ixdtf.rs b/components/timezone/src/ixdtf.rs index 9fd2f150e61..715de8c1521 100644 --- a/components/timezone/src/ixdtf.rs +++ b/components/timezone/src/ixdtf.rs @@ -3,8 +3,8 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::{ - CustomTimeZone, CustomZonedDateTime, InvalidOffsetError, MetazoneCalculator, TimeZoneIdMapper, - UtcOffset, ZoneOffsetCalculator, + CustomZonedDateTime, InvalidOffsetError, TimeZoneIdMapper, TimeZoneInfo, UtcOffset, + ZoneOffsetCalculator, ZoneVariant, }; use alloc::str::FromStr; use icu_calendar::{AnyCalendar, Date, DateError, DateTime, Iso, RangeError, Time}; @@ -76,9 +76,9 @@ impl UtcOffset { } } -// ==== CustomTimeZone methods and traits ==== +// ==== TimeZoneInfo methods and traits ==== -impl CustomTimeZone { +impl TimeZoneInfo { fn try_from_ixdtf_record(ixdtf_record: &IxdtfParseRecord) -> Result { match ixdtf_record { IxdtfParseRecord { @@ -113,9 +113,12 @@ impl CustomTimeZone { } fn try_from_utc_offset_record(record: &UTCOffsetRecord) -> Result { - Ok(Self::new_with_offset( - UtcOffset::try_from_utc_offset_record(record)?, - )) + Ok(Self { + time_zone_id: crate::TimeZoneBcp47Id::unknown(), + offset: Some(UtcOffset::try_from_utc_offset_record(record)?), + zone_variant: None, + local_time: None, + }) } fn try_from_time_zone_record( @@ -129,13 +132,8 @@ impl CustomTimeZone { let mapper = TimeZoneIdMapper::new(); let time_zone_id = mapper.as_borrowed().iana_bytes_to_bcp47(iana_identifier); - let mut tz = Self { - time_zone_id, - offset, - metazone_id: None, - zone_variant: None, - }; - + let mut zone_variant = None; + let mut local_time = None; if let (Some(date), Some(time)) = (date, time) { let iso = DateTime::::try_new_iso_datetime( date.year, @@ -145,10 +143,28 @@ impl CustomTimeZone { time.minute, time.second, )?; - tz.maybe_calculate_metazone(&MetazoneCalculator::new(), &iso); - tz.maybe_calculate_zone_variant(&ZoneOffsetCalculator::new(), &iso); + if let Some(offset) = offset { + if let Some((std_offset, dst_offset)) = ZoneOffsetCalculator::new() + .compute_offsets_from_time_zone(time_zone_id, &iso) + { + zone_variant = if offset == std_offset { + Some(ZoneVariant::standard()) + } else if Some(offset) == dst_offset { + Some(ZoneVariant::daylight()) + } else { + return Err(ParseError::InvalidOffsetError); + }; + } + } + local_time = Some((iso.date, iso.time)); }; - Ok(tz) + + Ok(Self { + time_zone_id, + offset, + zone_variant, + local_time, + }) } TimeZoneRecord::Offset(offset_record) => { let tz = Self::try_from_utc_offset_record(offset_record)?; @@ -170,8 +186,7 @@ impl CustomZonedDateTime { /// ✨ *Enabled with the `compiled_data` and `ixdtf` Cargo features.* /// /// ``` - /// use icu_timezone::{CustomZonedDateTime, CustomTimeZone, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; - /// use icu_timezone::provider::MetazoneId; + /// use icu_timezone::{CustomZonedDateTime, TimeZoneInfo, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; /// use tinystr::tinystr; /// /// let zoneddatetime = CustomZonedDateTime::try_iso_from_str("2024-08-08T12:08:19-05:00[America/Chicago]").unwrap(); @@ -187,13 +202,10 @@ impl CustomZonedDateTime { /// assert_eq!(zoneddatetime.time.minute.number(), 8); /// assert_eq!(zoneddatetime.time.second.number(), 19); /// assert_eq!(zoneddatetime.time.nanosecond.number(), 0); - /// assert_eq!(zoneddatetime.zone, CustomTimeZone { - /// offset: Some(UtcOffset::try_from_seconds(-18000).unwrap()), - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), - /// metazone_id: Some(Some(MetazoneId(tinystr!(4, "amce")))), - /// zone_variant: Some(ZoneVariant::daylight()), - /// }); - /// + /// assert_eq!(zoneddatetime.zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); + /// assert_eq!(zoneddatetime.zone.offset, Some(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(zoneddatetime.zone.zone_variant, Some(ZoneVariant::daylight())); + /// assert!(zoneddatetime.zone.local_time.is_some()); /// ``` /// /// For more information on date, time, and time zone parsing, @@ -222,7 +234,7 @@ impl CustomZonedDateTime { time_record.second, time_record.nanosecond, )?; - let time_zone = CustomTimeZone::try_from_ixdtf_record(ixdtf_record)?; + let time_zone = TimeZoneInfo::try_from_ixdtf_record(ixdtf_record)?; Ok(Self { date, @@ -256,8 +268,7 @@ impl CustomZonedDateTime { /// Basic usage: /// /// ``` - /// use icu_timezone::{CustomZonedDateTime, CustomTimeZone, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; - /// use icu_timezone::provider::MetazoneId; + /// use icu_timezone::{CustomZonedDateTime, TimeZoneInfo, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; /// use tinystr::tinystr; /// /// let zoneddatetime = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[America/Chicago][u-ca=hebrew]").unwrap(); @@ -273,12 +284,10 @@ impl CustomZonedDateTime { /// assert_eq!(zoneddatetime.time.minute.number(), 8); /// assert_eq!(zoneddatetime.time.second.number(), 19); /// assert_eq!(zoneddatetime.time.nanosecond.number(), 0); - /// assert_eq!(zoneddatetime.zone, CustomTimeZone { - /// offset: Some(UtcOffset::try_from_seconds(-18000).unwrap()), - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), - /// metazone_id: Some(Some(MetazoneId(tinystr!(4, "amce")))), - /// zone_variant: Some(ZoneVariant::daylight()), - /// }); + /// assert_eq!(zoneddatetime.zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); + /// assert_eq!(zoneddatetime.zone.offset, Some(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(zoneddatetime.zone.zone_variant, Some(ZoneVariant::daylight())); + /// assert!(zoneddatetime.zone.local_time.is_some()); /// ``` /// /// An IXDTF string can provide a time zone in two parts: the DateTime UTC Offset or the Time Zone @@ -292,11 +301,11 @@ impl CustomZonedDateTime { /// DateTime string. /// /// ``` - /// use icu_timezone::{CustomTimeZone, CustomZonedDateTime, UtcOffset}; + /// use icu_timezone::{TimeZoneInfo, CustomZonedDateTime, UtcOffset}; /// /// let tz_from_offset = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00").unwrap(); /// - /// assert_eq!(tz_from_offset.zone, CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(tz_from_offset.zone.offset, UtcOffset::try_from_seconds(-18000).ok()); /// ``` /// /// ## Time Zone Annotations @@ -304,21 +313,18 @@ impl CustomZonedDateTime { /// Below is an example of a time zone being provided by a time zone annotation. /// /// ``` - /// use icu_timezone::{CustomTimeZone, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id}; - /// use icu_timezone::provider::MetazoneId; + /// use icu_timezone::{TimeZoneInfo, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; /// use tinystr::tinystr; /// /// let tz_from_offset_annotation = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19[-05:00]").unwrap(); /// let tz_from_iana_annotation = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19[America/Chicago]").unwrap(); /// - /// assert_eq!(tz_from_offset_annotation.zone, CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(tz_from_offset_annotation.zone.offset, UtcOffset::try_from_seconds(-18000).ok()); /// - /// assert_eq!(tz_from_iana_annotation.zone, CustomTimeZone { - /// offset: None, - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), - /// metazone_id: Some(Some(MetazoneId(tinystr!(4, "amce")))), - /// zone_variant: None, - /// }); + /// assert_eq!(tz_from_iana_annotation.zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); + /// assert_eq!(tz_from_iana_annotation.zone.offset, None); + /// assert_eq!(tz_from_iana_annotation.zone.zone_variant, None); + /// assert!(tz_from_iana_annotation.zone.local_time.is_some()); /// ``` /// /// ## DateTime UTC Offset and Time Zone Annotations. @@ -328,31 +334,30 @@ impl CustomZonedDateTime { /// /// ### DateTime UTC Offset with IANA identifier annotation /// - /// In cases where the DateTime UTC Offset is provided and the IANA identifier, these will be returned without - /// verifying internal consistency. + /// In cases where the DateTime UTC Offset is provided and the IANA identifier, some validity checks are performed. /// /// ``` - /// use icu_timezone::{CustomTimeZone, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id, ZoneVariant}; - /// use icu_timezone::provider::MetazoneId; + /// use icu_timezone::{TimeZoneInfo, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id, ZoneVariant, ParseError}; /// use tinystr::tinystr; /// /// let consistent_tz_from_both = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[America/Chicago]").unwrap(); /// - /// assert_eq!(consistent_tz_from_both.zone, CustomTimeZone { - /// offset: Some(UtcOffset::try_from_seconds(-18000).unwrap()), - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uschi")), - /// metazone_id: Some(Some(MetazoneId(tinystr!(4, "amce")))), - /// zone_variant: Some(ZoneVariant::daylight()), - /// }); - /// - /// let inconsistent_tz_from_both = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[America/Los_Angeles]").unwrap(); - /// - /// assert_eq!(inconsistent_tz_from_both.zone, CustomTimeZone { - /// offset: Some(UtcOffset::try_from_seconds(-18000).unwrap()), - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "uslax")), - /// metazone_id: Some(Some(MetazoneId(tinystr!(4, "ampa")))), - /// zone_variant: None, - /// }); + /// + /// assert_eq!(consistent_tz_from_both.zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); + /// assert_eq!(consistent_tz_from_both.zone.offset, Some(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(consistent_tz_from_both.zone.zone_variant, Some(ZoneVariant::daylight())); + /// assert!(consistent_tz_from_both.zone.local_time.is_some()); + /// + /// // We know that America/Los_Angeles never used a -05:00 offset at any time of the year 2024 + /// assert_eq!( + /// CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[America/Los_Angeles]").unwrap_err(), + /// ParseError::InvalidOffsetError + /// ); + /// + /// // We don't know that America/Los_Angeles didn't use standard time (-08:00) in August + /// assert!( + /// CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-08:00[America/Los_Angeles]").is_ok() + /// ); /// ``` /// /// ### DateTime UTC offset with UTC Offset annotation. @@ -360,12 +365,12 @@ impl CustomZonedDateTime { /// These annotations must always be consistent as they should be either the same value or are inconsistent. /// /// ``` - /// use icu_timezone::{ParseError, CustomTimeZone, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id}; + /// use icu_timezone::{ParseError, TimeZoneInfo, CustomZonedDateTime, UtcOffset, TimeZoneBcp47Id}; /// use tinystr::tinystr; /// /// let consistent_tz_from_both = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[-05:00]").unwrap(); /// - /// assert_eq!(consistent_tz_from_both.zone, CustomTimeZone::new_with_offset(UtcOffset::try_from_seconds(-18000).unwrap())); + /// assert_eq!(consistent_tz_from_both.zone.offset, UtcOffset::try_from_seconds(-18000).ok()); /// /// /// let inconsistent_tz_from_both = CustomZonedDateTime::try_from_str("2024-08-08T12:08:19-05:00[+05:00]"); @@ -416,7 +421,7 @@ impl FromStr for CustomZonedDateTime { mod test { use ixdtf::parsers::IxdtfParser; - use crate::{CustomTimeZone, ParseError, UtcOffset}; + use crate::{ParseError, TimeZoneBcp47Id, TimeZoneInfo, UtcOffset}; #[test] fn max_possible_ixdtf_utc_offset() { @@ -433,7 +438,9 @@ mod test { let ixdtf_record = IxdtfParser::from_utf8("2024-08-08T12:08:19[Future/Zone]".as_bytes()) .parse() .unwrap(); - let result = CustomTimeZone::try_from_ixdtf_record(&ixdtf_record).unwrap(); - assert_eq!(result, CustomTimeZone::unknown()); + let result = TimeZoneInfo::try_from_ixdtf_record(&ixdtf_record).unwrap(); + assert_eq!(result.time_zone_id, TimeZoneBcp47Id::unknown()); + assert_eq!(result.offset, None); + assert_eq!(result.zone_variant, None); } } diff --git a/components/timezone/src/lib.rs b/components/timezone/src/lib.rs index d3795b237d5..96278e166cc 100644 --- a/components/timezone/src/lib.rs +++ b/components/timezone/src/lib.rs @@ -6,20 +6,12 @@ //! //! # Fields //! -//! In ICU4X, a [formattable time zone](CustomTimeZone) consists of four different fields: +//! In ICU4X, a [formattable time zone](TimeZoneInfo) consists of four different fields: //! -//! 1. The offset from UTC -//! 2. The time zone ID -//! 3. The metazone ID -//! 4. The zone variant, representing concepts such as Standard, Summer, Daylight, and Ramadan time -//! -//! ## UTC Offset -//! -//! The UTC offset precisely states the time difference between the time zone in question and -//! Coordinated Universal Time (UTC). -//! -//! In localized strings, it is often rendered as "UTC-6", meaning 6 hours less than UTC (some locales -//! use the term "GMT" instead of "UTC"). +//! 1. The time zone ID +//! 2. The offset from UTC +//! 3. The zone variant, representing concepts such as Standard, Summer, Daylight, and Ramadan time +//! 4. A timestamp, as time zone names can change over time //! //! ## Time Zone //! @@ -34,31 +26,17 @@ //! ICU4X uses BCP-47 time zone IDs for all of its APIs. To get a BCP-47 time zone from an //! IANA time zone, use [`TimeZoneIdMapper`]. //! -//! ## Metazone -//! -//! A metazone is a collection of multiple time zones that share the same localized formatting -//! at a particular date and time. -//! -//! For example, "America/Chicago" and "America/Indiana/Knox" both map to US Central Time, or -//! `"America_Central"`. -//! -//! The mapping from time zone to metazone depends on the date. For example, from 1991 to 2006, -//! "America/Indiana/Knox" mapped to US Eastern Time instead of US Central Time. -//! -//! As with time zone IDs, there are two interchangeable forms: -//! -//! 1. Long form, like `"America_Central"` -//! 2. Short form compatible with BCP-47, like `"amce"` +//! ## UTC Offset //! -//! ICU4X uses the short form. +//! The UTC offset precisely states the time difference between the time zone in question and +//! Coordinated Universal Time (UTC). //! -//! Note: in ICU4X, "metazone" is one word and "time zone" is two words, except for this crate -//! and module name, where "timezone" is used with no separators. See -//! . +//! In localized strings, it is often rendered as "UTC-6", meaning 6 hours less than UTC (some locales +//! use the term "GMT" instead of "UTC"). //! //! ## Zone Variant //! -//! Many metazones use different names and offsets in the summer than in the winter. In ICU4X, +//! Many zones use different names and offsets in the summer than in the winter. In ICU4X, //! this is called the _zone variant_. //! //! CLDR has two zone variants, named `"standard"` and `"daylight"`. However, the mapping of these @@ -66,48 +44,29 @@ //! consistently represent winter versus summer time. //! //! Note: It is optional (not required) to set the zone variant when constructing a -//! [`CustomTimeZone`]. Therefore, the list of possible variants does not include a generic variant +//! [`TimeZoneInfo`]. Therefore, the list of possible variants does not include a generic variant //! to represent the lack of a preference. //! -//! # Calculations -//! -//! In date/time processing, normally only a subset of information is available, and the other -//! fields must be computed from it. -//! -//! The following calculations are currently supported or will be supported: -//! -//! 1. Time Zone + Local DateTime → Metazone ([`MetazoneCalculator`]) -//! 2. Time Zone + Local DateTime + Offset → Zone Variant ([`ZoneOffsetCalculator`]) -//! //! # Examples //! -//! Create a time zone for which the offset and time zone ID are already known, and calculate -//! the metazone based on a certain local datetime: -//! //! ``` //! use icu::calendar::DateTime; -//! use icu::timezone::CustomTimeZone; +//! use icu::timezone::TimeZoneInfo; //! use icu::timezone::UtcOffset; -//! use icu::timezone::MetazoneCalculator; //! use icu::timezone::TimeZoneBcp47Id; //! use icu::timezone::TimeZoneIdMapper; //! use tinystr::{tinystr, TinyAsciiStr}; //! -//! // Create a time zone for America/Chicago at UTC-6: -//! let mut time_zone = CustomTimeZone::new_with_offset("-0600".parse().unwrap()); //! let mapper = TimeZoneIdMapper::new(); -//! time_zone.time_zone_id = -//! mapper.as_borrowed().iana_to_bcp47("America/Chicago"); +//! // Create a time zone for America/Chicago at UTC-6: +//! let mut time_zone = TimeZoneInfo { +//! time_zone_id: mapper.as_borrowed().iana_to_bcp47("America/Chicago"), +//! offset: Some("-0600".parse().unwrap()), +//! ..TimeZoneInfo::unknown() +//! }; //! //! // Alternatively, set it directly from the BCP-47 ID //! assert_eq!(time_zone.time_zone_id, TimeZoneBcp47Id(tinystr!(8, "uschi"))); -//! -//! // Compute the metazone at January 1, 2022: -//! let mzc = MetazoneCalculator::new(); -//! let datetime = DateTime::try_new_iso_datetime(2022, 1, 1, 0, 0, 0).unwrap(); -//! time_zone.maybe_calculate_metazone(&mzc, &datetime); -//! -//! assert_eq!("amce", time_zone.metazone_id.unwrap().unwrap().0.as_str()); //! ``` // https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations @@ -130,7 +89,6 @@ extern crate alloc; mod error; mod ids; -mod metazone; pub mod provider; mod time_zone; mod types; @@ -146,9 +104,8 @@ pub use ids::{ TimeZoneIdMapper, TimeZoneIdMapperBorrowed, TimeZoneIdMapperWithFastCanonicalization, TimeZoneIdMapperWithFastCanonicalizationBorrowed, }; -pub use metazone::MetazoneCalculator; -pub use provider::{MetazoneId, TimeZoneBcp47Id}; -pub use time_zone::CustomTimeZone; +pub use provider::TimeZoneBcp47Id; +pub use time_zone::TimeZoneInfo; pub use types::{UtcOffset, ZoneVariant}; pub use windows_tz::{WindowsTimeZoneMapper, WindowsTimeZoneMapperBorrowed}; pub use zone_offset::ZoneOffsetCalculator; diff --git a/components/timezone/src/metazone.rs b/components/timezone/src/metazone.rs deleted file mode 100644 index 9f1be08ddac..00000000000 --- a/components/timezone/src/metazone.rs +++ /dev/null @@ -1,128 +0,0 @@ -// This file is part of ICU4X. For terms of use, please see the file -// called LICENSE at the top level of the ICU4X source tree -// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - -use crate::provider::{MetazoneId, TimeZoneBcp47Id}; - -use crate::provider::MetazonePeriodV1Marker; -use icu_calendar::DateTime; -use icu_calendar::Iso; -use icu_provider::prelude::*; -use zerovec::ule::AsULE; - -/// [`MetazoneCalculator`] uses data from the [data provider] to calculate metazone id. -/// -/// [data provider]: icu_provider -#[derive(Debug)] -pub struct MetazoneCalculator { - pub(super) metazone_period: DataPayload, -} - -#[cfg(feature = "compiled_data")] -impl Default for MetazoneCalculator { - fn default() -> Self { - Self::new() - } -} - -impl MetazoneCalculator { - /// Constructs a `MetazoneCalculator` using compiled data. - /// - /// ✨ *Enabled with the `compiled_data` Cargo feature.* - /// - /// [📚 Help choosing a constructor](icu_provider::constructors) - #[cfg(feature = "compiled_data")] - #[inline] - pub const fn new() -> Self { - MetazoneCalculator { - metazone_period: DataPayload::from_static_ref( - crate::provider::Baked::SINGLETON_METAZONE_PERIOD_V1_MARKER, - ), - } - } - - icu_provider::gen_any_buffer_data_constructors!(() -> error: DataError, - functions: [ - new: skip, - 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( - provider: &(impl DataProvider + ?Sized), - ) -> Result { - let metazone_period = provider.load(Default::default())?.payload; - Ok(Self { metazone_period }) - } - - /// Calculate metazone id from timezone id and local datetime. - /// - /// # Examples - /// - /// ``` - /// use icu::calendar::DateTime; - /// use icu::timezone::provider::{MetazoneId, TimeZoneBcp47Id}; - /// use icu::timezone::MetazoneCalculator; - /// use tinystr::tinystr; - /// - /// let mzc = MetazoneCalculator::new(); - /// - /// assert_eq!( - /// mzc.compute_metazone_from_time_zone( - /// TimeZoneBcp47Id(tinystr!(8, "gugum")), - /// &DateTime::try_new_iso_datetime(1969, 1, 1, 0, 0, 0).unwrap() - /// ), - /// None - /// ); - /// - /// assert_eq!( - /// mzc.compute_metazone_from_time_zone( - /// TimeZoneBcp47Id(tinystr!(8, "gugum")), - /// &DateTime::try_new_iso_datetime(1970, 1, 1, 0, 0, 0).unwrap() - /// ), - /// Some(MetazoneId(tinystr!(4, "guam"))) - /// ); - /// - /// assert_eq!( - /// mzc.compute_metazone_from_time_zone( - /// TimeZoneBcp47Id(tinystr!(8, "gugum")), - /// &DateTime::try_new_iso_datetime(1975, 1, 1, 0, 0, 0).unwrap() - /// ), - /// Some(MetazoneId(tinystr!(4, "guam"))) - /// ); - /// - /// assert_eq!( - /// mzc.compute_metazone_from_time_zone( - /// TimeZoneBcp47Id(tinystr!(8, "gugum")), - /// &DateTime::try_new_iso_datetime(2000, 12, 22, 15, 0, 0).unwrap() - /// ), - /// Some(MetazoneId(tinystr!(4, "cham"))) - /// ); - /// ``` - pub fn compute_metazone_from_time_zone( - &self, - time_zone_id: TimeZoneBcp47Id, - local_datetime: &DateTime, - ) -> Option { - match self.metazone_period.get().0.get0(&time_zone_id) { - Some(cursor) => { - let mut metazone_id = None; - let minutes_since_local_unix_epoch = - local_datetime.minutes_since_local_unix_epoch(); - for (minutes, id) in cursor.iter1() { - if minutes_since_local_unix_epoch >= i32::from_unaligned(*minutes) { - metazone_id = id.get() - } else { - break; - } - } - metazone_id - } - None => None, - } - } -} diff --git a/components/timezone/src/provider.rs b/components/timezone/src/provider.rs index 968184f9b78..fbe55399704 100644 --- a/components/timezone/src/provider.rs +++ b/components/timezone/src/provider.rs @@ -45,7 +45,6 @@ const _: () = { make_provider!(Baked); impl_bcp47_to_iana_map_v1_marker!(Baked); impl_iana_to_bcp47_map_v3_marker!(Baked); - impl_metazone_period_v1_marker!(Baked); impl_windows_zones_to_bcp47_map_v1_marker!(Baked); impl_zone_offset_period_v1_marker!(Baked); }; @@ -53,7 +52,6 @@ const _: () = { #[cfg(feature = "datagen")] /// The latest minimum set of markers required by this component. pub const MARKERS: &[DataMarkerInfo] = &[ - MetazonePeriodV1Marker::INFO, names::Bcp47ToIanaMapV1Marker::INFO, names::IanaToBcp47MapV3Marker::INFO, windows::WindowsZonesToBcp47MapV1Marker::INFO, @@ -113,66 +111,6 @@ impl<'a> zerovec::maps::ZeroMapKV<'a> for TimeZoneBcp47Id { type OwnedType = TimeZoneBcp47Id; } -/// Metazone ID in a compact format -/// -///
-/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, -/// including in SemVer minor releases. While the serde representation of data structs is guaranteed -/// to be stable, their Rust representation might not be. Use with caution. -///
-#[repr(transparent)] -#[derive(Debug, Clone, Copy, Eq, Ord, PartialEq, PartialOrd, yoke::Yokeable, ULE, Hash)] -#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))] -#[cfg_attr(feature = "datagen", databake(path = icu_timezone::provider))] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] -pub struct MetazoneId(pub TinyAsciiStr<4>); - -impl AsULE for MetazoneId { - type ULE = Self; - - #[inline] - fn to_unaligned(self) -> Self::ULE { - self - } - - #[inline] - fn from_unaligned(unaligned: Self::ULE) -> Self { - unaligned - } -} - -impl<'a> zerovec::maps::ZeroMapKV<'a> for MetazoneId { - type Container = ZeroVec<'a, MetazoneId>; - type Slice = ZeroSlice; - type GetType = MetazoneId; - type OwnedType = MetazoneId; -} - -/// An ICU4X mapping to the metazones at a given period. -/// See CLDR-JSON metaZones.json for more context. -/// -///
-/// 🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways, -/// including in SemVer minor releases. While the serde representation of data structs is guaranteed -/// to be stable, their Rust representation might not be. Use with caution. -///
-#[icu_provider::data_struct(marker( - MetazonePeriodV1Marker, - "time_zone/metazone_period@1", - singleton -))] -#[derive(PartialEq, Debug, Clone, Default)] -#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))] -#[cfg_attr(feature = "datagen", databake(path = icu_timezone::provider))] -#[cfg_attr(feature = "serde", derive(serde::Deserialize))] -#[yoke(prove_covariance_manually)] -pub struct MetazonePeriodV1<'data>( - /// The default mapping between period and metazone id. The second level key is a wall-clock time represented as - /// the number of minutes since the local unix epoch. It represents when the metazone started to be used. - #[cfg_attr(feature = "serde", serde(borrow))] - pub ZeroMap2d<'data, TimeZoneBcp47Id, IsoMinutesSinceEpoch, Option>, -); - /// Storage type for storing UTC offsets as eights of an hour. pub type EighthsOfHourOffset = i8; /// Storage type for storing `DateTime` as minutes since the UNIX epoch. diff --git a/components/timezone/src/time_zone.rs b/components/timezone/src/time_zone.rs index 4324e83a863..a975725db8a 100644 --- a/components/timezone/src/time_zone.rs +++ b/components/timezone/src/time_zone.rs @@ -2,243 +2,46 @@ // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). -#[cfg(feature = "compiled_data")] -use crate::TimeZoneIdMapper; -use crate::{ - MetazoneCalculator, MetazoneId, TimeZoneBcp47Id, UtcOffset, ZoneOffsetCalculator, ZoneVariant, -}; -use icu_calendar::{DateTime, Iso}; -use tinystr::TinyAsciiStr; +use crate::{TimeZoneBcp47Id, UtcOffset, ZoneVariant}; +use icu_calendar::{Date, Iso, Time}; /// A utility type that can hold time zone information. -/// -/// The UTC offset is used as a final fallback for formatting. The other three fields are used -/// for more human-friendly rendering of the time zone. -/// -/// This type does not enforce that the four fields are consistent with each other. If they do not -/// represent a real time zone, unexpected results when formatting may occur. -/// -/// # Examples -/// -/// ``` -/// use icu::timezone::CustomTimeZone; -/// -/// let tz1 = CustomTimeZone::utc(); -/// -/// let tz2: CustomTimeZone = -/// "+05:00".parse().expect("Failed to parse a time zone."); -/// ``` #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[allow(clippy::exhaustive_structs)] // these four fields fully cover the needs of UTS 35 -pub struct CustomTimeZone { - /// The UTC offset. - pub offset: Option, - /// The BCP47 time-zone identifier +pub struct TimeZoneInfo { + /// The BCP47 time-zone identifier. pub time_zone_id: TimeZoneBcp47Id, - /// The CLDR metazone identifier + /// The UTC offset, if known. /// - /// This is `Some(None)` if the metazone has been resolved, but the time zone does not - /// have a metazone. - pub metazone_id: Option>, - /// The time variant e.g. daylight or standard + /// This field is not enforced to be consistent with the time zone id. + pub offset: Option, + /// The time variant e.g. daylight or standard, if known. pub zone_variant: Option, + /// The time at which to interpret the time zone. + /// + /// This can be set in order to get correct historical time zone names. + /// If it's not set, the most recent data for the time zone will be used. + pub local_time: Option<(Date, Time)>, } -impl CustomTimeZone { - /// Creates a new [`CustomTimeZone`] with the given UTC offset. - pub const fn new_with_offset(offset: UtcOffset) -> Self { - Self { - offset: Some(offset), - time_zone_id: TimeZoneBcp47Id::unknown(), - metazone_id: None, - zone_variant: None, - } - } - - /// Creates a new [`CustomTimeZone`] with a given BCP47 time zone identifier. - pub const fn new_with_bcp47_id(time_zone_id: TimeZoneBcp47Id) -> Self { - Self { - offset: None, - time_zone_id, - metazone_id: None, - zone_variant: None, - } - } - - /// Creates a time zone with no information. - /// - /// One or more fields must be specified before this time zone is usable. +impl TimeZoneInfo { + /// Creates a time zone info with no information. pub const fn unknown() -> Self { Self { offset: None, time_zone_id: TimeZoneBcp47Id::unknown(), - metazone_id: Some(None), zone_variant: None, + local_time: None, } } - /// Creates a time zone infallibly from raw parts. - pub const fn from_parts( - offset_eighths_of_hour: i8, - time_zone_id: TinyAsciiStr<8>, - metazone_id: TinyAsciiStr<4>, - zone_variant: TinyAsciiStr<2>, - ) -> Self { - Self { - offset: Some(UtcOffset::from_eighths_of_hour(offset_eighths_of_hour)), - time_zone_id: TimeZoneBcp47Id(time_zone_id), - metazone_id: Some(Some(MetazoneId(metazone_id))), - zone_variant: Some(ZoneVariant(zone_variant)), - } - } - - /// Creates a new [`CustomTimeZone`] for the UTC time zone. + /// Creates a new [`TimeZoneInfo`] for the UTC time zone. pub const fn utc() -> Self { Self { offset: Some(UtcOffset::zero()), time_zone_id: TimeZoneBcp47Id(tinystr::tinystr!(8, "utc")), - metazone_id: Some(Some(MetazoneId(tinystr::tinystr!(4, "utc")))), zone_variant: Some(ZoneVariant::standard()), + local_time: None, } } - - /// Parse a [`CustomTimeZone`] from a UTF-8 string representing a UTC offset - /// or an IANA time zone identifier. - /// - /// This is a convenience constructor that uses compiled data. For a custom data provider, - /// use [`UtcOffset`] or [`TimeZoneIdMapper`] directly. - /// - /// To parse from an IXDTF string, use [`CustomZonedDateTime::try_iso_from_str`]. - /// - /// ✨ *Enabled with the `compiled_data` Cargo feature.* - /// - /// # Examples - /// - /// ``` - /// use icu::timezone::CustomTimeZone; - /// use icu::timezone::UtcOffset; - /// - /// let tz0: CustomTimeZone = CustomTimeZone::from_str("Z"); - /// let tz1: CustomTimeZone = CustomTimeZone::from_str("+02"); - /// let tz2: CustomTimeZone = CustomTimeZone::from_str("-0230"); - /// let tz3: CustomTimeZone = CustomTimeZone::from_str("+02:30"); - /// - /// assert_eq!(tz0.offset.map(UtcOffset::to_seconds), Some(0)); - /// assert_eq!(tz1.offset.map(UtcOffset::to_seconds), Some(7200)); - /// assert_eq!(tz2.offset.map(UtcOffset::to_seconds), Some(-9000)); - /// assert_eq!(tz3.offset.map(UtcOffset::to_seconds), Some(9000)); - /// ``` - /// - /// [`CustomZonedDateTime::try_iso_from_str`]: crate::CustomZonedDateTime::try_iso_from_str - #[cfg(feature = "compiled_data")] - #[inline] - #[allow(clippy::should_implement_trait)] // does implement trait - pub fn from_str(s: &str) -> Self { - Self::from_utf8(s.as_bytes()) - } - - /// See [`Self::from_str`] - #[cfg(feature = "compiled_data")] - pub fn from_utf8(code_units: &[u8]) -> Self { - if let Ok(offset) = UtcOffset::try_from_utf8(code_units) { - return Self { - offset: Some(offset), - time_zone_id: TimeZoneBcp47Id::unknown(), - metazone_id: None, - zone_variant: None, - }; - } - let mapper = TimeZoneIdMapper::new(); - Self { - offset: None, - time_zone_id: mapper.as_borrowed().iana_bytes_to_bcp47(code_units), - metazone_id: None, - zone_variant: None, - } - } - - /// Infer the metazone ID. - /// - /// # Examples - /// - /// ``` - /// use icu::calendar::DateTime; - /// use icu::timezone::MetazoneId; - /// use icu::timezone::TimeZoneBcp47Id; - /// use icu::timezone::CustomTimeZone; - /// use icu::timezone::MetazoneCalculator; - /// use tinystr::tinystr; - /// - /// let mzc = MetazoneCalculator::new(); - /// let mut tz = CustomTimeZone::new_with_bcp47_id(TimeZoneBcp47Id(tinystr!(8, "gugum"))); - /// tz.maybe_calculate_metazone( - /// &mzc, - /// &DateTime::try_new_iso_datetime(1971, 10, 31, 2, 0, 0).unwrap(), - /// ); - /// assert_eq!(tz.metazone_id.unwrap(), Some(MetazoneId(tinystr!(4, "guam")))); - /// ``` - pub fn maybe_calculate_metazone( - &mut self, - metazone_calculator: &MetazoneCalculator, - local_datetime: &DateTime, - ) -> &mut Self { - self.metazone_id = Some( - metazone_calculator.compute_metazone_from_time_zone(self.time_zone_id, local_datetime), - ); - self - } - - /// Infer the zone variant. - /// - /// # Examples - /// - /// ``` - /// use icu::calendar::DateTime; - /// use icu::timezone::ZoneVariant; - /// use icu::timezone::TimeZoneBcp47Id; - /// use icu::timezone::CustomTimeZone; - /// use icu::timezone::ZoneOffsetCalculator; - /// use tinystr::tinystr; - /// - /// let zoc = ZoneOffsetCalculator::new(); - /// let mut tz = CustomTimeZone { - /// offset: Some("+10".parse().expect("Failed to parse a UTC offset.")), - /// time_zone_id: TimeZoneBcp47Id(tinystr!(8, "gugum")), - /// metazone_id: None, - /// zone_variant: None, - /// }; - /// tz.maybe_calculate_zone_variant( - /// &zoc, - /// &DateTime::try_new_iso_datetime(1971, 10, 31, 2, 0, 0).unwrap(), - /// ); - /// assert_eq!(tz.zone_variant, Some(ZoneVariant::standard())); - /// ``` - pub fn maybe_calculate_zone_variant( - &mut self, - zone_offset_calculator: &ZoneOffsetCalculator, - local_datetime: &DateTime, - ) -> &mut Self { - if let Some(offset) = self.offset { - if let Some((std, dst)) = zone_offset_calculator - .compute_offsets_from_time_zone(self.time_zone_id, local_datetime) - { - if offset == std { - self.zone_variant = Some(ZoneVariant::standard()); - } else if Some(offset) == dst { - self.zone_variant = Some(ZoneVariant::daylight()); - } - } - } - self - } -} - -#[cfg(feature = "compiled_data")] -impl core::str::FromStr for CustomTimeZone { - type Err = core::convert::Infallible; - - #[inline] - fn from_str(s: &str) -> Result { - Ok(Self::from_str(s)) - } } diff --git a/components/timezone/src/zoned_datetime.rs b/components/timezone/src/zoned_datetime.rs index 136e0de364e..b96518398c6 100644 --- a/components/timezone/src/zoned_datetime.rs +++ b/components/timezone/src/zoned_datetime.rs @@ -4,7 +4,7 @@ use icu_calendar::{AsCalendar, Date, Iso, Time}; -use crate::CustomTimeZone; +use crate::TimeZoneInfo; /// A date and time local to a specified custom time zone. #[derive(Debug)] @@ -15,7 +15,7 @@ pub struct CustomZonedDateTime { /// The time, local to the time zone pub time: Time, /// The time zone - pub zone: CustomTimeZone, + pub zone: TimeZoneInfo, } impl CustomZonedDateTime
{ diff --git a/ffi/capi/bindings/c/CustomTimeZone.d.h b/ffi/capi/bindings/c/CustomTimeZone.d.h deleted file mode 100644 index 1aa32727a20..00000000000 --- a/ffi/capi/bindings/c/CustomTimeZone.d.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef CustomTimeZone_D_H -#define CustomTimeZone_D_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - - - - - -typedef struct CustomTimeZone CustomTimeZone; - - - - -#endif // CustomTimeZone_D_H diff --git a/ffi/capi/bindings/c/CustomTimeZone.h b/ffi/capi/bindings/c/CustomTimeZone.h deleted file mode 100644 index 8f8476b2e6f..00000000000 --- a/ffi/capi/bindings/c/CustomTimeZone.h +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef CustomTimeZone_H -#define CustomTimeZone_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - -#include "IsoDateTime.d.h" -#include "MetazoneCalculator.d.h" -#include "TimeZoneIdMapper.d.h" -#include "ZoneOffsetCalculator.d.h" - -#include "CustomTimeZone.d.h" - - - - - - -CustomTimeZone* icu4x_CustomTimeZone_from_string_mv1(DiplomatStringView s); - -CustomTimeZone* icu4x_CustomTimeZone_unknown_mv1(void); - -CustomTimeZone* icu4x_CustomTimeZone_utc_mv1(void); - -typedef struct icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result; -icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result icu4x_CustomTimeZone_try_set_offset_seconds_mv1(CustomTimeZone* self, int32_t offset_seconds); - -void icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(CustomTimeZone* self, int8_t offset_eighths_of_hour); - -typedef struct icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result {union {int8_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result; -icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(const CustomTimeZone* self); - -void icu4x_CustomTimeZone_clear_offset_mv1(CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_offset_seconds_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_seconds_mv1_result; -icu4x_CustomTimeZone_offset_seconds_mv1_result icu4x_CustomTimeZone_offset_seconds_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_is_offset_positive_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_offset_positive_mv1_result; -icu4x_CustomTimeZone_is_offset_positive_mv1_result icu4x_CustomTimeZone_is_offset_positive_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_is_offset_zero_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_offset_zero_mv1_result; -icu4x_CustomTimeZone_is_offset_zero_mv1_result icu4x_CustomTimeZone_is_offset_zero_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_offset_hours_part_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_hours_part_mv1_result; -icu4x_CustomTimeZone_offset_hours_part_mv1_result icu4x_CustomTimeZone_offset_hours_part_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_offset_minutes_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_minutes_part_mv1_result; -icu4x_CustomTimeZone_offset_minutes_part_mv1_result icu4x_CustomTimeZone_offset_minutes_part_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_offset_seconds_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_seconds_part_mv1_result; -icu4x_CustomTimeZone_offset_seconds_part_mv1_result icu4x_CustomTimeZone_offset_seconds_part_mv1(const CustomTimeZone* self); - -void icu4x_CustomTimeZone_set_time_zone_id_mv1(CustomTimeZone* self, DiplomatStringView id); - -void icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(CustomTimeZone* self, const TimeZoneIdMapper* mapper, DiplomatStringView id); - -void icu4x_CustomTimeZone_time_zone_id_mv1(const CustomTimeZone* self, DiplomatWrite* write); - -void icu4x_CustomTimeZone_set_metazone_id_mv1(CustomTimeZone* self, DiplomatStringView id); - -typedef struct icu4x_CustomTimeZone_metazone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_metazone_id_mv1_result; -icu4x_CustomTimeZone_metazone_id_mv1_result icu4x_CustomTimeZone_metazone_id_mv1(const CustomTimeZone* self, DiplomatWrite* write); - -typedef struct icu4x_CustomTimeZone_try_set_zone_variant_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_zone_variant_mv1_result; -icu4x_CustomTimeZone_try_set_zone_variant_mv1_result icu4x_CustomTimeZone_try_set_zone_variant_mv1(CustomTimeZone* self, DiplomatStringView id); - -void icu4x_CustomTimeZone_clear_zone_variant_mv1(CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_zone_variant_mv1_result { bool is_ok;} icu4x_CustomTimeZone_zone_variant_mv1_result; -icu4x_CustomTimeZone_zone_variant_mv1_result icu4x_CustomTimeZone_zone_variant_mv1(const CustomTimeZone* self, DiplomatWrite* write); - -void icu4x_CustomTimeZone_set_standard_time_mv1(CustomTimeZone* self); - -void icu4x_CustomTimeZone_set_daylight_time_mv1(CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_is_standard_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_standard_time_mv1_result; -icu4x_CustomTimeZone_is_standard_time_mv1_result icu4x_CustomTimeZone_is_standard_time_mv1(const CustomTimeZone* self); - -typedef struct icu4x_CustomTimeZone_is_daylight_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_daylight_time_mv1_result; -icu4x_CustomTimeZone_is_daylight_time_mv1_result icu4x_CustomTimeZone_is_daylight_time_mv1(const CustomTimeZone* self); - -void icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(CustomTimeZone* self, const MetazoneCalculator* metazone_calculator, const IsoDateTime* local_datetime); - -void icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(CustomTimeZone* self, const ZoneOffsetCalculator* zone_offset_calculator, const IsoDateTime* local_datetime); - - -void icu4x_CustomTimeZone_destroy_mv1(CustomTimeZone* self); - - - - - -#endif // CustomTimeZone_H diff --git a/ffi/capi/bindings/c/GregorianZonedDateTimeFormatter.h b/ffi/capi/bindings/c/GregorianZonedDateTimeFormatter.h index cf013ceb128..d73d2db9422 100644 --- a/ffi/capi/bindings/c/GregorianZonedDateTimeFormatter.h +++ b/ffi/capi/bindings/c/GregorianZonedDateTimeFormatter.h @@ -7,12 +7,12 @@ #include #include "diplomat_runtime.h" -#include "CustomTimeZone.d.h" #include "DataProvider.d.h" #include "DateTimeLength.d.h" #include "Error.d.h" #include "IsoDateTime.d.h" #include "Locale.d.h" +#include "TimeZoneInfo.d.h" #include "GregorianZonedDateTimeFormatter.d.h" @@ -24,7 +24,7 @@ typedef struct icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result {union {GregorianZonedDateTimeFormatter* ok; Error err;}; bool is_ok;} icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result; icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1(const DataProvider* provider, const Locale* locale, DateTimeLength length); -void icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const GregorianZonedDateTimeFormatter* self, const IsoDateTime* datetime, const CustomTimeZone* time_zone, DiplomatWrite* write); +void icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const GregorianZonedDateTimeFormatter* self, const IsoDateTime* datetime, const TimeZoneInfo* time_zone, DiplomatWrite* write); void icu4x_GregorianZonedDateTimeFormatter_destroy_mv1(GregorianZonedDateTimeFormatter* self); diff --git a/ffi/capi/bindings/c/MetazoneCalculator.d.h b/ffi/capi/bindings/c/MetazoneCalculator.d.h deleted file mode 100644 index 4c36c75d5fb..00000000000 --- a/ffi/capi/bindings/c/MetazoneCalculator.d.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef MetazoneCalculator_D_H -#define MetazoneCalculator_D_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - - - - - -typedef struct MetazoneCalculator MetazoneCalculator; - - - - -#endif // MetazoneCalculator_D_H diff --git a/ffi/capi/bindings/c/MetazoneCalculator.h b/ffi/capi/bindings/c/MetazoneCalculator.h deleted file mode 100644 index 807fcc5f36b..00000000000 --- a/ffi/capi/bindings/c/MetazoneCalculator.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef MetazoneCalculator_H -#define MetazoneCalculator_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - -#include "DataError.d.h" -#include "DataProvider.d.h" - -#include "MetazoneCalculator.d.h" - - - - - - -typedef struct icu4x_MetazoneCalculator_create_mv1_result {union {MetazoneCalculator* ok; DataError err;}; bool is_ok;} icu4x_MetazoneCalculator_create_mv1_result; -icu4x_MetazoneCalculator_create_mv1_result icu4x_MetazoneCalculator_create_mv1(const DataProvider* provider); - - -void icu4x_MetazoneCalculator_destroy_mv1(MetazoneCalculator* self); - - - - - -#endif // MetazoneCalculator_H diff --git a/ffi/capi/bindings/c/TimeZoneInfo.d.h b/ffi/capi/bindings/c/TimeZoneInfo.d.h new file mode 100644 index 00000000000..2eff6b782b3 --- /dev/null +++ b/ffi/capi/bindings/c/TimeZoneInfo.d.h @@ -0,0 +1,19 @@ +#ifndef TimeZoneInfo_D_H +#define TimeZoneInfo_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef struct TimeZoneInfo TimeZoneInfo; + + + + +#endif // TimeZoneInfo_D_H diff --git a/ffi/capi/bindings/c/TimeZoneInfo.h b/ffi/capi/bindings/c/TimeZoneInfo.h new file mode 100644 index 00000000000..e7ac529c124 --- /dev/null +++ b/ffi/capi/bindings/c/TimeZoneInfo.h @@ -0,0 +1,92 @@ +#ifndef TimeZoneInfo_H +#define TimeZoneInfo_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "IsoDateTime.d.h" +#include "TimeZoneIdMapper.d.h" + +#include "TimeZoneInfo.d.h" + + + + + + +TimeZoneInfo* icu4x_TimeZoneInfo_unknown_mv1(void); + +TimeZoneInfo* icu4x_TimeZoneInfo_utc_mv1(void); + +typedef struct icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result; +icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(TimeZoneInfo* self, int32_t offset_seconds); + +void icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(TimeZoneInfo* self, int8_t offset_eighths_of_hour); + +typedef struct icu4x_TimeZoneInfo_try_set_offset_str_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_offset_str_mv1_result; +icu4x_TimeZoneInfo_try_set_offset_str_mv1_result icu4x_TimeZoneInfo_try_set_offset_str_mv1(TimeZoneInfo* self, DiplomatStringView offset); + +typedef struct icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result {union {int8_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result; +icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(const TimeZoneInfo* self); + +void icu4x_TimeZoneInfo_clear_offset_mv1(TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_offset_seconds_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_seconds_mv1_result; +icu4x_TimeZoneInfo_offset_seconds_mv1_result icu4x_TimeZoneInfo_offset_seconds_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_is_offset_positive_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_offset_positive_mv1_result; +icu4x_TimeZoneInfo_is_offset_positive_mv1_result icu4x_TimeZoneInfo_is_offset_positive_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_is_offset_zero_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_offset_zero_mv1_result; +icu4x_TimeZoneInfo_is_offset_zero_mv1_result icu4x_TimeZoneInfo_is_offset_zero_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_offset_hours_part_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_hours_part_mv1_result; +icu4x_TimeZoneInfo_offset_hours_part_mv1_result icu4x_TimeZoneInfo_offset_hours_part_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_offset_minutes_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_minutes_part_mv1_result; +icu4x_TimeZoneInfo_offset_minutes_part_mv1_result icu4x_TimeZoneInfo_offset_minutes_part_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_offset_seconds_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_seconds_part_mv1_result; +icu4x_TimeZoneInfo_offset_seconds_part_mv1_result icu4x_TimeZoneInfo_offset_seconds_part_mv1(const TimeZoneInfo* self); + +void icu4x_TimeZoneInfo_set_time_zone_id_mv1(TimeZoneInfo* self, DiplomatStringView id); + +void icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(TimeZoneInfo* self, const TimeZoneIdMapper* mapper, DiplomatStringView id); + +void icu4x_TimeZoneInfo_time_zone_id_mv1(const TimeZoneInfo* self, DiplomatWrite* write); + +typedef struct icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result; +icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result icu4x_TimeZoneInfo_try_set_zone_variant_mv1(TimeZoneInfo* self, DiplomatStringView id); + +void icu4x_TimeZoneInfo_clear_zone_variant_mv1(TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_zone_variant_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_zone_variant_mv1_result; +icu4x_TimeZoneInfo_zone_variant_mv1_result icu4x_TimeZoneInfo_zone_variant_mv1(const TimeZoneInfo* self, DiplomatWrite* write); + +void icu4x_TimeZoneInfo_set_standard_time_mv1(TimeZoneInfo* self); + +void icu4x_TimeZoneInfo_set_daylight_time_mv1(TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_is_standard_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_standard_time_mv1_result; +icu4x_TimeZoneInfo_is_standard_time_mv1_result icu4x_TimeZoneInfo_is_standard_time_mv1(const TimeZoneInfo* self); + +typedef struct icu4x_TimeZoneInfo_is_daylight_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_daylight_time_mv1_result; +icu4x_TimeZoneInfo_is_daylight_time_mv1_result icu4x_TimeZoneInfo_is_daylight_time_mv1(const TimeZoneInfo* self); + +void icu4x_TimeZoneInfo_set_local_time_mv1(TimeZoneInfo* self, const IsoDateTime* datetime); + +void icu4x_TimeZoneInfo_clear_local_time_mv1(TimeZoneInfo* self); + +IsoDateTime* icu4x_TimeZoneInfo_get_local_time_mv1(const TimeZoneInfo* self); + + +void icu4x_TimeZoneInfo_destroy_mv1(TimeZoneInfo* self); + + + + + +#endif // TimeZoneInfo_H diff --git a/ffi/capi/bindings/c/ZoneOffsetCalculator.d.h b/ffi/capi/bindings/c/ZoneOffsetCalculator.d.h deleted file mode 100644 index 9ca7fa94480..00000000000 --- a/ffi/capi/bindings/c/ZoneOffsetCalculator.d.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ZoneOffsetCalculator_D_H -#define ZoneOffsetCalculator_D_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - - - - - -typedef struct ZoneOffsetCalculator ZoneOffsetCalculator; - - - - -#endif // ZoneOffsetCalculator_D_H diff --git a/ffi/capi/bindings/c/ZoneOffsetCalculator.h b/ffi/capi/bindings/c/ZoneOffsetCalculator.h deleted file mode 100644 index 9f6b2d00c37..00000000000 --- a/ffi/capi/bindings/c/ZoneOffsetCalculator.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef ZoneOffsetCalculator_H -#define ZoneOffsetCalculator_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - -#include "DataError.d.h" -#include "DataProvider.d.h" - -#include "ZoneOffsetCalculator.d.h" - - - - - - -typedef struct icu4x_ZoneOffsetCalculator_create_mv1_result {union {ZoneOffsetCalculator* ok; DataError err;}; bool is_ok;} icu4x_ZoneOffsetCalculator_create_mv1_result; -icu4x_ZoneOffsetCalculator_create_mv1_result icu4x_ZoneOffsetCalculator_create_mv1(const DataProvider* provider); - - -void icu4x_ZoneOffsetCalculator_destroy_mv1(ZoneOffsetCalculator* self); - - - - - -#endif // ZoneOffsetCalculator_H diff --git a/ffi/capi/bindings/c/ZonedDateTimeFormatter.h b/ffi/capi/bindings/c/ZonedDateTimeFormatter.h index 0bb003ba7cc..99616873d45 100644 --- a/ffi/capi/bindings/c/ZonedDateTimeFormatter.h +++ b/ffi/capi/bindings/c/ZonedDateTimeFormatter.h @@ -7,13 +7,13 @@ #include #include "diplomat_runtime.h" -#include "CustomTimeZone.d.h" #include "DataProvider.d.h" #include "DateTime.d.h" #include "DateTimeLength.d.h" #include "Error.d.h" #include "IsoDateTime.d.h" #include "Locale.d.h" +#include "TimeZoneInfo.d.h" #include "ZonedDateTimeFormatter.d.h" @@ -26,10 +26,10 @@ typedef struct icu4x_ZonedDateTimeFormatter_create_with_length_mv1_result {union icu4x_ZonedDateTimeFormatter_create_with_length_mv1_result icu4x_ZonedDateTimeFormatter_create_with_length_mv1(const DataProvider* provider, const Locale* locale, DateTimeLength length); typedef struct icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result {union { Error err;}; bool is_ok;} icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result; -icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(const ZonedDateTimeFormatter* self, const DateTime* datetime, const CustomTimeZone* time_zone, DiplomatWrite* write); +icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(const ZonedDateTimeFormatter* self, const DateTime* datetime, const TimeZoneInfo* time_zone, DiplomatWrite* write); typedef struct icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result {union { Error err;}; bool is_ok;} icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result; -icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const ZonedDateTimeFormatter* self, const IsoDateTime* datetime, const CustomTimeZone* time_zone, DiplomatWrite* write); +icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const ZonedDateTimeFormatter* self, const IsoDateTime* datetime, const TimeZoneInfo* time_zone, DiplomatWrite* write); void icu4x_ZonedDateTimeFormatter_destroy_mv1(ZonedDateTimeFormatter* self); diff --git a/ffi/capi/bindings/cpp/icu4x/CustomTimeZone.hpp b/ffi/capi/bindings/cpp/icu4x/CustomTimeZone.hpp deleted file mode 100644 index 39fb4c8e701..00000000000 --- a/ffi/capi/bindings/cpp/icu4x/CustomTimeZone.hpp +++ /dev/null @@ -1,264 +0,0 @@ -#ifndef icu4x_CustomTimeZone_HPP -#define icu4x_CustomTimeZone_HPP - -#include "CustomTimeZone.d.hpp" - -#include -#include -#include -#include -#include -#include -#include "../diplomat_runtime.hpp" -#include "IsoDateTime.hpp" -#include "MetazoneCalculator.hpp" -#include "TimeZoneIdMapper.hpp" -#include "TimeZoneInvalidOffsetError.hpp" -#include "ZoneOffsetCalculator.hpp" - - -namespace icu4x { -namespace capi { - extern "C" { - - icu4x::capi::CustomTimeZone* icu4x_CustomTimeZone_from_string_mv1(diplomat::capi::DiplomatStringView s); - - icu4x::capi::CustomTimeZone* icu4x_CustomTimeZone_unknown_mv1(void); - - icu4x::capi::CustomTimeZone* icu4x_CustomTimeZone_utc_mv1(void); - - typedef struct icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result; - icu4x_CustomTimeZone_try_set_offset_seconds_mv1_result icu4x_CustomTimeZone_try_set_offset_seconds_mv1(icu4x::capi::CustomTimeZone* self, int32_t offset_seconds); - - void icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(icu4x::capi::CustomTimeZone* self, int8_t offset_eighths_of_hour); - - typedef struct icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result {union {int8_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result; - icu4x_CustomTimeZone_offset_eighths_of_hour_mv1_result icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(const icu4x::capi::CustomTimeZone* self); - - void icu4x_CustomTimeZone_clear_offset_mv1(icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_offset_seconds_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_seconds_mv1_result; - icu4x_CustomTimeZone_offset_seconds_mv1_result icu4x_CustomTimeZone_offset_seconds_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_is_offset_positive_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_offset_positive_mv1_result; - icu4x_CustomTimeZone_is_offset_positive_mv1_result icu4x_CustomTimeZone_is_offset_positive_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_is_offset_zero_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_offset_zero_mv1_result; - icu4x_CustomTimeZone_is_offset_zero_mv1_result icu4x_CustomTimeZone_is_offset_zero_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_offset_hours_part_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_hours_part_mv1_result; - icu4x_CustomTimeZone_offset_hours_part_mv1_result icu4x_CustomTimeZone_offset_hours_part_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_offset_minutes_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_minutes_part_mv1_result; - icu4x_CustomTimeZone_offset_minutes_part_mv1_result icu4x_CustomTimeZone_offset_minutes_part_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_offset_seconds_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_CustomTimeZone_offset_seconds_part_mv1_result; - icu4x_CustomTimeZone_offset_seconds_part_mv1_result icu4x_CustomTimeZone_offset_seconds_part_mv1(const icu4x::capi::CustomTimeZone* self); - - void icu4x_CustomTimeZone_set_time_zone_id_mv1(icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatStringView id); - - void icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(icu4x::capi::CustomTimeZone* self, const icu4x::capi::TimeZoneIdMapper* mapper, diplomat::capi::DiplomatStringView id); - - void icu4x_CustomTimeZone_time_zone_id_mv1(const icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatWrite* write); - - void icu4x_CustomTimeZone_set_metazone_id_mv1(icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatStringView id); - - typedef struct icu4x_CustomTimeZone_metazone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_metazone_id_mv1_result; - icu4x_CustomTimeZone_metazone_id_mv1_result icu4x_CustomTimeZone_metazone_id_mv1(const icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatWrite* write); - - typedef struct icu4x_CustomTimeZone_try_set_zone_variant_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_zone_variant_mv1_result; - icu4x_CustomTimeZone_try_set_zone_variant_mv1_result icu4x_CustomTimeZone_try_set_zone_variant_mv1(icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatStringView id); - - void icu4x_CustomTimeZone_clear_zone_variant_mv1(icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_zone_variant_mv1_result { bool is_ok;} icu4x_CustomTimeZone_zone_variant_mv1_result; - icu4x_CustomTimeZone_zone_variant_mv1_result icu4x_CustomTimeZone_zone_variant_mv1(const icu4x::capi::CustomTimeZone* self, diplomat::capi::DiplomatWrite* write); - - void icu4x_CustomTimeZone_set_standard_time_mv1(icu4x::capi::CustomTimeZone* self); - - void icu4x_CustomTimeZone_set_daylight_time_mv1(icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_is_standard_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_standard_time_mv1_result; - icu4x_CustomTimeZone_is_standard_time_mv1_result icu4x_CustomTimeZone_is_standard_time_mv1(const icu4x::capi::CustomTimeZone* self); - - typedef struct icu4x_CustomTimeZone_is_daylight_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_is_daylight_time_mv1_result; - icu4x_CustomTimeZone_is_daylight_time_mv1_result icu4x_CustomTimeZone_is_daylight_time_mv1(const icu4x::capi::CustomTimeZone* self); - - void icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(icu4x::capi::CustomTimeZone* self, const icu4x::capi::MetazoneCalculator* metazone_calculator, const icu4x::capi::IsoDateTime* local_datetime); - - void icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(icu4x::capi::CustomTimeZone* self, const icu4x::capi::ZoneOffsetCalculator* zone_offset_calculator, const icu4x::capi::IsoDateTime* local_datetime); - - - void icu4x_CustomTimeZone_destroy_mv1(CustomTimeZone* self); - - } // extern "C" -} // namespace capi -} // namespace - -inline std::unique_ptr icu4x::CustomTimeZone::from_string(std::string_view s) { - auto result = icu4x::capi::icu4x_CustomTimeZone_from_string_mv1({s.data(), s.size()}); - return std::unique_ptr(icu4x::CustomTimeZone::FromFFI(result)); -} - -inline std::unique_ptr icu4x::CustomTimeZone::unknown() { - auto result = icu4x::capi::icu4x_CustomTimeZone_unknown_mv1(); - return std::unique_ptr(icu4x::CustomTimeZone::FromFFI(result)); -} - -inline std::unique_ptr icu4x::CustomTimeZone::utc() { - auto result = icu4x::capi::icu4x_CustomTimeZone_utc_mv1(); - return std::unique_ptr(icu4x::CustomTimeZone::FromFFI(result)); -} - -inline diplomat::result icu4x::CustomTimeZone::try_set_offset_seconds(int32_t offset_seconds) { - auto result = icu4x::capi::icu4x_CustomTimeZone_try_set_offset_seconds_mv1(this->AsFFI(), - offset_seconds); - return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(icu4x::TimeZoneInvalidOffsetError {})); -} - -inline void icu4x::CustomTimeZone::set_offset_eighths_of_hour(int8_t offset_eighths_of_hour) { - icu4x::capi::icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(this->AsFFI(), - offset_eighths_of_hour); -} - -inline std::optional icu4x::CustomTimeZone::offset_eighths_of_hour() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline void icu4x::CustomTimeZone::clear_offset() { - icu4x::capi::icu4x_CustomTimeZone_clear_offset_mv1(this->AsFFI()); -} - -inline std::optional icu4x::CustomTimeZone::offset_seconds() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_offset_seconds_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::is_offset_positive() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_is_offset_positive_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::is_offset_zero() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_is_offset_zero_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::offset_hours_part() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_offset_hours_part_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::offset_minutes_part() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_offset_minutes_part_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::offset_seconds_part() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_offset_seconds_part_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline void icu4x::CustomTimeZone::set_time_zone_id(std::string_view id) { - icu4x::capi::icu4x_CustomTimeZone_set_time_zone_id_mv1(this->AsFFI(), - {id.data(), id.size()}); -} - -inline void icu4x::CustomTimeZone::set_iana_time_zone_id(const icu4x::TimeZoneIdMapper& mapper, std::string_view id) { - icu4x::capi::icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(this->AsFFI(), - mapper.AsFFI(), - {id.data(), id.size()}); -} - -inline std::string icu4x::CustomTimeZone::time_zone_id() const { - std::string output; - diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); - icu4x::capi::icu4x_CustomTimeZone_time_zone_id_mv1(this->AsFFI(), - &write); - return output; -} - -inline void icu4x::CustomTimeZone::set_metazone_id(std::string_view id) { - icu4x::capi::icu4x_CustomTimeZone_set_metazone_id_mv1(this->AsFFI(), - {id.data(), id.size()}); -} - -inline std::optional icu4x::CustomTimeZone::metazone_id() const { - std::string output; - diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); - auto result = icu4x::capi::icu4x_CustomTimeZone_metazone_id_mv1(this->AsFFI(), - &write); - return result.is_ok ? std::optional(std::move(output)) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::try_set_zone_variant(std::string_view id) { - auto result = icu4x::capi::icu4x_CustomTimeZone_try_set_zone_variant_mv1(this->AsFFI(), - {id.data(), id.size()}); - return result.is_ok ? std::optional() : std::nullopt; -} - -inline void icu4x::CustomTimeZone::clear_zone_variant() { - icu4x::capi::icu4x_CustomTimeZone_clear_zone_variant_mv1(this->AsFFI()); -} - -inline std::optional icu4x::CustomTimeZone::zone_variant() const { - std::string output; - diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); - auto result = icu4x::capi::icu4x_CustomTimeZone_zone_variant_mv1(this->AsFFI(), - &write); - return result.is_ok ? std::optional(std::move(output)) : std::nullopt; -} - -inline void icu4x::CustomTimeZone::set_standard_time() { - icu4x::capi::icu4x_CustomTimeZone_set_standard_time_mv1(this->AsFFI()); -} - -inline void icu4x::CustomTimeZone::set_daylight_time() { - icu4x::capi::icu4x_CustomTimeZone_set_daylight_time_mv1(this->AsFFI()); -} - -inline std::optional icu4x::CustomTimeZone::is_standard_time() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_is_standard_time_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline std::optional icu4x::CustomTimeZone::is_daylight_time() const { - auto result = icu4x::capi::icu4x_CustomTimeZone_is_daylight_time_mv1(this->AsFFI()); - return result.is_ok ? std::optional(result.ok) : std::nullopt; -} - -inline void icu4x::CustomTimeZone::maybe_calculate_metazone(const icu4x::MetazoneCalculator& metazone_calculator, const icu4x::IsoDateTime& local_datetime) { - icu4x::capi::icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(this->AsFFI(), - metazone_calculator.AsFFI(), - local_datetime.AsFFI()); -} - -inline void icu4x::CustomTimeZone::maybe_calculate_zone_variant(const icu4x::ZoneOffsetCalculator& zone_offset_calculator, const icu4x::IsoDateTime& local_datetime) { - icu4x::capi::icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(this->AsFFI(), - zone_offset_calculator.AsFFI(), - local_datetime.AsFFI()); -} - -inline const icu4x::capi::CustomTimeZone* icu4x::CustomTimeZone::AsFFI() const { - return reinterpret_cast(this); -} - -inline icu4x::capi::CustomTimeZone* icu4x::CustomTimeZone::AsFFI() { - return reinterpret_cast(this); -} - -inline const icu4x::CustomTimeZone* icu4x::CustomTimeZone::FromFFI(const icu4x::capi::CustomTimeZone* ptr) { - return reinterpret_cast(ptr); -} - -inline icu4x::CustomTimeZone* icu4x::CustomTimeZone::FromFFI(icu4x::capi::CustomTimeZone* ptr) { - return reinterpret_cast(ptr); -} - -inline void icu4x::CustomTimeZone::operator delete(void* ptr) { - icu4x::capi::icu4x_CustomTimeZone_destroy_mv1(reinterpret_cast(ptr)); -} - - -#endif // icu4x_CustomTimeZone_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.d.hpp b/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.d.hpp index bed29d0eefd..9fa4fc3c71c 100644 --- a/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.d.hpp @@ -10,8 +10,6 @@ #include "../diplomat_runtime.hpp" namespace icu4x { -namespace capi { struct CustomTimeZone; } -class CustomTimeZone; namespace capi { struct DataProvider; } class DataProvider; namespace capi { struct GregorianZonedDateTimeFormatter; } @@ -20,6 +18,8 @@ namespace capi { struct IsoDateTime; } class IsoDateTime; namespace capi { struct Locale; } class Locale; +namespace capi { struct TimeZoneInfo; } +class TimeZoneInfo; class DateTimeLength; class Error; } @@ -37,7 +37,7 @@ class GregorianZonedDateTimeFormatter { inline static diplomat::result, icu4x::Error> create_with_length(const icu4x::DataProvider& provider, const icu4x::Locale& locale, icu4x::DateTimeLength length); - inline std::string format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::CustomTimeZone& time_zone) const; + inline std::string format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const; inline const icu4x::capi::GregorianZonedDateTimeFormatter* AsFFI() const; inline icu4x::capi::GregorianZonedDateTimeFormatter* AsFFI(); diff --git a/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.hpp b/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.hpp index 7b3a9935d34..070ebe23d85 100644 --- a/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.hpp +++ b/ffi/capi/bindings/cpp/icu4x/GregorianZonedDateTimeFormatter.hpp @@ -10,12 +10,12 @@ #include #include #include "../diplomat_runtime.hpp" -#include "CustomTimeZone.hpp" #include "DataProvider.hpp" #include "DateTimeLength.hpp" #include "Error.hpp" #include "IsoDateTime.hpp" #include "Locale.hpp" +#include "TimeZoneInfo.hpp" namespace icu4x { @@ -25,7 +25,7 @@ namespace capi { typedef struct icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result {union {icu4x::capi::GregorianZonedDateTimeFormatter* ok; icu4x::capi::Error err;}; bool is_ok;} icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result; icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1_result icu4x_GregorianZonedDateTimeFormatter_create_with_length_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* locale, icu4x::capi::DateTimeLength length); - void icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const icu4x::capi::GregorianZonedDateTimeFormatter* self, const icu4x::capi::IsoDateTime* datetime, const icu4x::capi::CustomTimeZone* time_zone, diplomat::capi::DiplomatWrite* write); + void icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const icu4x::capi::GregorianZonedDateTimeFormatter* self, const icu4x::capi::IsoDateTime* datetime, const icu4x::capi::TimeZoneInfo* time_zone, diplomat::capi::DiplomatWrite* write); void icu4x_GregorianZonedDateTimeFormatter_destroy_mv1(GregorianZonedDateTimeFormatter* self); @@ -41,7 +41,7 @@ inline diplomat::result, return result.is_ok ? diplomat::result, icu4x::Error>(diplomat::Ok>(std::unique_ptr(icu4x::GregorianZonedDateTimeFormatter::FromFFI(result.ok)))) : diplomat::result, icu4x::Error>(diplomat::Err(icu4x::Error::FromFFI(result.err))); } -inline std::string icu4x::GregorianZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::CustomTimeZone& time_zone) const { +inline std::string icu4x::GregorianZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); icu4x::capi::icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(this->AsFFI(), diff --git a/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.d.hpp b/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.d.hpp deleted file mode 100644 index a60308a2493..00000000000 --- a/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.d.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef icu4x_MetazoneCalculator_D_HPP -#define icu4x_MetazoneCalculator_D_HPP - -#include -#include -#include -#include -#include -#include -#include "../diplomat_runtime.hpp" - -namespace icu4x { -namespace capi { struct DataProvider; } -class DataProvider; -namespace capi { struct MetazoneCalculator; } -class MetazoneCalculator; -class DataError; -} - - -namespace icu4x { -namespace capi { - struct MetazoneCalculator; -} // namespace capi -} // namespace - -namespace icu4x { -class MetazoneCalculator { -public: - - inline static diplomat::result, icu4x::DataError> create(const icu4x::DataProvider& provider); - - inline const icu4x::capi::MetazoneCalculator* AsFFI() const; - inline icu4x::capi::MetazoneCalculator* AsFFI(); - inline static const icu4x::MetazoneCalculator* FromFFI(const icu4x::capi::MetazoneCalculator* ptr); - inline static icu4x::MetazoneCalculator* FromFFI(icu4x::capi::MetazoneCalculator* ptr); - inline static void operator delete(void* ptr); -private: - MetazoneCalculator() = delete; - MetazoneCalculator(const icu4x::MetazoneCalculator&) = delete; - MetazoneCalculator(icu4x::MetazoneCalculator&&) noexcept = delete; - MetazoneCalculator operator=(const icu4x::MetazoneCalculator&) = delete; - MetazoneCalculator operator=(icu4x::MetazoneCalculator&&) noexcept = delete; - static void operator delete[](void*, size_t) = delete; -}; - -} // namespace -#endif // icu4x_MetazoneCalculator_D_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.hpp b/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.hpp deleted file mode 100644 index 6274dd544f1..00000000000 --- a/ffi/capi/bindings/cpp/icu4x/MetazoneCalculator.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef icu4x_MetazoneCalculator_HPP -#define icu4x_MetazoneCalculator_HPP - -#include "MetazoneCalculator.d.hpp" - -#include -#include -#include -#include -#include -#include -#include "../diplomat_runtime.hpp" -#include "DataError.hpp" -#include "DataProvider.hpp" - - -namespace icu4x { -namespace capi { - extern "C" { - - typedef struct icu4x_MetazoneCalculator_create_mv1_result {union {icu4x::capi::MetazoneCalculator* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_MetazoneCalculator_create_mv1_result; - icu4x_MetazoneCalculator_create_mv1_result icu4x_MetazoneCalculator_create_mv1(const icu4x::capi::DataProvider* provider); - - - void icu4x_MetazoneCalculator_destroy_mv1(MetazoneCalculator* self); - - } // extern "C" -} // namespace capi -} // namespace - -inline diplomat::result, icu4x::DataError> icu4x::MetazoneCalculator::create(const icu4x::DataProvider& provider) { - auto result = icu4x::capi::icu4x_MetazoneCalculator_create_mv1(provider.AsFFI()); - return result.is_ok ? diplomat::result, icu4x::DataError>(diplomat::Ok>(std::unique_ptr(icu4x::MetazoneCalculator::FromFFI(result.ok)))) : diplomat::result, icu4x::DataError>(diplomat::Err(icu4x::DataError::FromFFI(result.err))); -} - -inline const icu4x::capi::MetazoneCalculator* icu4x::MetazoneCalculator::AsFFI() const { - return reinterpret_cast(this); -} - -inline icu4x::capi::MetazoneCalculator* icu4x::MetazoneCalculator::AsFFI() { - return reinterpret_cast(this); -} - -inline const icu4x::MetazoneCalculator* icu4x::MetazoneCalculator::FromFFI(const icu4x::capi::MetazoneCalculator* ptr) { - return reinterpret_cast(ptr); -} - -inline icu4x::MetazoneCalculator* icu4x::MetazoneCalculator::FromFFI(icu4x::capi::MetazoneCalculator* ptr) { - return reinterpret_cast(ptr); -} - -inline void icu4x::MetazoneCalculator::operator delete(void* ptr) { - icu4x::capi::icu4x_MetazoneCalculator_destroy_mv1(reinterpret_cast(ptr)); -} - - -#endif // icu4x_MetazoneCalculator_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/CustomTimeZone.d.hpp b/ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.d.hpp similarity index 53% rename from ffi/capi/bindings/cpp/icu4x/CustomTimeZone.d.hpp rename to ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.d.hpp index 58100214db0..c579fbdd924 100644 --- a/ffi/capi/bindings/cpp/icu4x/CustomTimeZone.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.d.hpp @@ -1,5 +1,5 @@ -#ifndef icu4x_CustomTimeZone_D_HPP -#define icu4x_CustomTimeZone_D_HPP +#ifndef icu4x_TimeZoneInfo_D_HPP +#define icu4x_TimeZoneInfo_D_HPP #include #include @@ -10,40 +10,36 @@ #include "../diplomat_runtime.hpp" namespace icu4x { -namespace capi { struct CustomTimeZone; } -class CustomTimeZone; namespace capi { struct IsoDateTime; } class IsoDateTime; -namespace capi { struct MetazoneCalculator; } -class MetazoneCalculator; namespace capi { struct TimeZoneIdMapper; } class TimeZoneIdMapper; -namespace capi { struct ZoneOffsetCalculator; } -class ZoneOffsetCalculator; +namespace capi { struct TimeZoneInfo; } +class TimeZoneInfo; struct TimeZoneInvalidOffsetError; } namespace icu4x { namespace capi { - struct CustomTimeZone; + struct TimeZoneInfo; } // namespace capi } // namespace namespace icu4x { -class CustomTimeZone { +class TimeZoneInfo { public: - inline static std::unique_ptr from_string(std::string_view s); + inline static std::unique_ptr unknown(); - inline static std::unique_ptr unknown(); - - inline static std::unique_ptr utc(); + inline static std::unique_ptr utc(); inline diplomat::result try_set_offset_seconds(int32_t offset_seconds); inline void set_offset_eighths_of_hour(int8_t offset_eighths_of_hour); + inline diplomat::result try_set_offset_str(std::string_view offset); + inline std::optional offset_eighths_of_hour() const; inline void clear_offset(); @@ -66,10 +62,6 @@ class CustomTimeZone { inline std::string time_zone_id() const; - inline void set_metazone_id(std::string_view id); - - inline std::optional metazone_id() const; - inline std::optional try_set_zone_variant(std::string_view id); inline void clear_zone_variant(); @@ -84,23 +76,25 @@ class CustomTimeZone { inline std::optional is_daylight_time() const; - inline void maybe_calculate_metazone(const icu4x::MetazoneCalculator& metazone_calculator, const icu4x::IsoDateTime& local_datetime); + inline void set_local_time(const icu4x::IsoDateTime& datetime); + + inline void clear_local_time(); - inline void maybe_calculate_zone_variant(const icu4x::ZoneOffsetCalculator& zone_offset_calculator, const icu4x::IsoDateTime& local_datetime); + inline std::unique_ptr get_local_time() const; - inline const icu4x::capi::CustomTimeZone* AsFFI() const; - inline icu4x::capi::CustomTimeZone* AsFFI(); - inline static const icu4x::CustomTimeZone* FromFFI(const icu4x::capi::CustomTimeZone* ptr); - inline static icu4x::CustomTimeZone* FromFFI(icu4x::capi::CustomTimeZone* ptr); + inline const icu4x::capi::TimeZoneInfo* AsFFI() const; + inline icu4x::capi::TimeZoneInfo* AsFFI(); + inline static const icu4x::TimeZoneInfo* FromFFI(const icu4x::capi::TimeZoneInfo* ptr); + inline static icu4x::TimeZoneInfo* FromFFI(icu4x::capi::TimeZoneInfo* ptr); inline static void operator delete(void* ptr); private: - CustomTimeZone() = delete; - CustomTimeZone(const icu4x::CustomTimeZone&) = delete; - CustomTimeZone(icu4x::CustomTimeZone&&) noexcept = delete; - CustomTimeZone operator=(const icu4x::CustomTimeZone&) = delete; - CustomTimeZone operator=(icu4x::CustomTimeZone&&) noexcept = delete; + TimeZoneInfo() = delete; + TimeZoneInfo(const icu4x::TimeZoneInfo&) = delete; + TimeZoneInfo(icu4x::TimeZoneInfo&&) noexcept = delete; + TimeZoneInfo operator=(const icu4x::TimeZoneInfo&) = delete; + TimeZoneInfo operator=(icu4x::TimeZoneInfo&&) noexcept = delete; static void operator delete[](void*, size_t) = delete; }; } // namespace -#endif // icu4x_CustomTimeZone_D_HPP +#endif // icu4x_TimeZoneInfo_D_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.hpp b/ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.hpp new file mode 100644 index 00000000000..93d3f18606f --- /dev/null +++ b/ffi/capi/bindings/cpp/icu4x/TimeZoneInfo.hpp @@ -0,0 +1,250 @@ +#ifndef icu4x_TimeZoneInfo_HPP +#define icu4x_TimeZoneInfo_HPP + +#include "TimeZoneInfo.d.hpp" + +#include +#include +#include +#include +#include +#include +#include "../diplomat_runtime.hpp" +#include "IsoDateTime.hpp" +#include "TimeZoneIdMapper.hpp" +#include "TimeZoneInvalidOffsetError.hpp" + + +namespace icu4x { +namespace capi { + extern "C" { + + icu4x::capi::TimeZoneInfo* icu4x_TimeZoneInfo_unknown_mv1(void); + + icu4x::capi::TimeZoneInfo* icu4x_TimeZoneInfo_utc_mv1(void); + + typedef struct icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result; + icu4x_TimeZoneInfo_try_set_offset_seconds_mv1_result icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(icu4x::capi::TimeZoneInfo* self, int32_t offset_seconds); + + void icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(icu4x::capi::TimeZoneInfo* self, int8_t offset_eighths_of_hour); + + typedef struct icu4x_TimeZoneInfo_try_set_offset_str_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_offset_str_mv1_result; + icu4x_TimeZoneInfo_try_set_offset_str_mv1_result icu4x_TimeZoneInfo_try_set_offset_str_mv1(icu4x::capi::TimeZoneInfo* self, diplomat::capi::DiplomatStringView offset); + + typedef struct icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result {union {int8_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result; + icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1_result icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(const icu4x::capi::TimeZoneInfo* self); + + void icu4x_TimeZoneInfo_clear_offset_mv1(icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_offset_seconds_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_seconds_mv1_result; + icu4x_TimeZoneInfo_offset_seconds_mv1_result icu4x_TimeZoneInfo_offset_seconds_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_is_offset_positive_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_offset_positive_mv1_result; + icu4x_TimeZoneInfo_is_offset_positive_mv1_result icu4x_TimeZoneInfo_is_offset_positive_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_is_offset_zero_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_offset_zero_mv1_result; + icu4x_TimeZoneInfo_is_offset_zero_mv1_result icu4x_TimeZoneInfo_is_offset_zero_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_offset_hours_part_mv1_result {union {int32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_hours_part_mv1_result; + icu4x_TimeZoneInfo_offset_hours_part_mv1_result icu4x_TimeZoneInfo_offset_hours_part_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_offset_minutes_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_minutes_part_mv1_result; + icu4x_TimeZoneInfo_offset_minutes_part_mv1_result icu4x_TimeZoneInfo_offset_minutes_part_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_offset_seconds_part_mv1_result {union {uint32_t ok; }; bool is_ok;} icu4x_TimeZoneInfo_offset_seconds_part_mv1_result; + icu4x_TimeZoneInfo_offset_seconds_part_mv1_result icu4x_TimeZoneInfo_offset_seconds_part_mv1(const icu4x::capi::TimeZoneInfo* self); + + void icu4x_TimeZoneInfo_set_time_zone_id_mv1(icu4x::capi::TimeZoneInfo* self, diplomat::capi::DiplomatStringView id); + + void icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(icu4x::capi::TimeZoneInfo* self, const icu4x::capi::TimeZoneIdMapper* mapper, diplomat::capi::DiplomatStringView id); + + void icu4x_TimeZoneInfo_time_zone_id_mv1(const icu4x::capi::TimeZoneInfo* self, diplomat::capi::DiplomatWrite* write); + + typedef struct icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result; + icu4x_TimeZoneInfo_try_set_zone_variant_mv1_result icu4x_TimeZoneInfo_try_set_zone_variant_mv1(icu4x::capi::TimeZoneInfo* self, diplomat::capi::DiplomatStringView id); + + void icu4x_TimeZoneInfo_clear_zone_variant_mv1(icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_zone_variant_mv1_result { bool is_ok;} icu4x_TimeZoneInfo_zone_variant_mv1_result; + icu4x_TimeZoneInfo_zone_variant_mv1_result icu4x_TimeZoneInfo_zone_variant_mv1(const icu4x::capi::TimeZoneInfo* self, diplomat::capi::DiplomatWrite* write); + + void icu4x_TimeZoneInfo_set_standard_time_mv1(icu4x::capi::TimeZoneInfo* self); + + void icu4x_TimeZoneInfo_set_daylight_time_mv1(icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_is_standard_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_standard_time_mv1_result; + icu4x_TimeZoneInfo_is_standard_time_mv1_result icu4x_TimeZoneInfo_is_standard_time_mv1(const icu4x::capi::TimeZoneInfo* self); + + typedef struct icu4x_TimeZoneInfo_is_daylight_time_mv1_result {union {bool ok; }; bool is_ok;} icu4x_TimeZoneInfo_is_daylight_time_mv1_result; + icu4x_TimeZoneInfo_is_daylight_time_mv1_result icu4x_TimeZoneInfo_is_daylight_time_mv1(const icu4x::capi::TimeZoneInfo* self); + + void icu4x_TimeZoneInfo_set_local_time_mv1(icu4x::capi::TimeZoneInfo* self, const icu4x::capi::IsoDateTime* datetime); + + void icu4x_TimeZoneInfo_clear_local_time_mv1(icu4x::capi::TimeZoneInfo* self); + + icu4x::capi::IsoDateTime* icu4x_TimeZoneInfo_get_local_time_mv1(const icu4x::capi::TimeZoneInfo* self); + + + void icu4x_TimeZoneInfo_destroy_mv1(TimeZoneInfo* self); + + } // extern "C" +} // namespace capi +} // namespace + +inline std::unique_ptr icu4x::TimeZoneInfo::unknown() { + auto result = icu4x::capi::icu4x_TimeZoneInfo_unknown_mv1(); + return std::unique_ptr(icu4x::TimeZoneInfo::FromFFI(result)); +} + +inline std::unique_ptr icu4x::TimeZoneInfo::utc() { + auto result = icu4x::capi::icu4x_TimeZoneInfo_utc_mv1(); + return std::unique_ptr(icu4x::TimeZoneInfo::FromFFI(result)); +} + +inline diplomat::result icu4x::TimeZoneInfo::try_set_offset_seconds(int32_t offset_seconds) { + auto result = icu4x::capi::icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(this->AsFFI(), + offset_seconds); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(icu4x::TimeZoneInvalidOffsetError {})); +} + +inline void icu4x::TimeZoneInfo::set_offset_eighths_of_hour(int8_t offset_eighths_of_hour) { + icu4x::capi::icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(this->AsFFI(), + offset_eighths_of_hour); +} + +inline diplomat::result icu4x::TimeZoneInfo::try_set_offset_str(std::string_view offset) { + auto result = icu4x::capi::icu4x_TimeZoneInfo_try_set_offset_str_mv1(this->AsFFI(), + {offset.data(), offset.size()}); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(icu4x::TimeZoneInvalidOffsetError {})); +} + +inline std::optional icu4x::TimeZoneInfo::offset_eighths_of_hour() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline void icu4x::TimeZoneInfo::clear_offset() { + icu4x::capi::icu4x_TimeZoneInfo_clear_offset_mv1(this->AsFFI()); +} + +inline std::optional icu4x::TimeZoneInfo::offset_seconds() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_offset_seconds_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::is_offset_positive() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_is_offset_positive_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::is_offset_zero() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_is_offset_zero_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::offset_hours_part() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_offset_hours_part_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::offset_minutes_part() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_offset_minutes_part_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::offset_seconds_part() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_offset_seconds_part_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline void icu4x::TimeZoneInfo::set_time_zone_id(std::string_view id) { + icu4x::capi::icu4x_TimeZoneInfo_set_time_zone_id_mv1(this->AsFFI(), + {id.data(), id.size()}); +} + +inline void icu4x::TimeZoneInfo::set_iana_time_zone_id(const icu4x::TimeZoneIdMapper& mapper, std::string_view id) { + icu4x::capi::icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(this->AsFFI(), + mapper.AsFFI(), + {id.data(), id.size()}); +} + +inline std::string icu4x::TimeZoneInfo::time_zone_id() const { + std::string output; + diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); + icu4x::capi::icu4x_TimeZoneInfo_time_zone_id_mv1(this->AsFFI(), + &write); + return output; +} + +inline std::optional icu4x::TimeZoneInfo::try_set_zone_variant(std::string_view id) { + auto result = icu4x::capi::icu4x_TimeZoneInfo_try_set_zone_variant_mv1(this->AsFFI(), + {id.data(), id.size()}); + return result.is_ok ? std::optional() : std::nullopt; +} + +inline void icu4x::TimeZoneInfo::clear_zone_variant() { + icu4x::capi::icu4x_TimeZoneInfo_clear_zone_variant_mv1(this->AsFFI()); +} + +inline std::optional icu4x::TimeZoneInfo::zone_variant() const { + std::string output; + diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); + auto result = icu4x::capi::icu4x_TimeZoneInfo_zone_variant_mv1(this->AsFFI(), + &write); + return result.is_ok ? std::optional(std::move(output)) : std::nullopt; +} + +inline void icu4x::TimeZoneInfo::set_standard_time() { + icu4x::capi::icu4x_TimeZoneInfo_set_standard_time_mv1(this->AsFFI()); +} + +inline void icu4x::TimeZoneInfo::set_daylight_time() { + icu4x::capi::icu4x_TimeZoneInfo_set_daylight_time_mv1(this->AsFFI()); +} + +inline std::optional icu4x::TimeZoneInfo::is_standard_time() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_is_standard_time_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline std::optional icu4x::TimeZoneInfo::is_daylight_time() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_is_daylight_time_mv1(this->AsFFI()); + return result.is_ok ? std::optional(result.ok) : std::nullopt; +} + +inline void icu4x::TimeZoneInfo::set_local_time(const icu4x::IsoDateTime& datetime) { + icu4x::capi::icu4x_TimeZoneInfo_set_local_time_mv1(this->AsFFI(), + datetime.AsFFI()); +} + +inline void icu4x::TimeZoneInfo::clear_local_time() { + icu4x::capi::icu4x_TimeZoneInfo_clear_local_time_mv1(this->AsFFI()); +} + +inline std::unique_ptr icu4x::TimeZoneInfo::get_local_time() const { + auto result = icu4x::capi::icu4x_TimeZoneInfo_get_local_time_mv1(this->AsFFI()); + return std::unique_ptr(icu4x::IsoDateTime::FromFFI(result)); +} + +inline const icu4x::capi::TimeZoneInfo* icu4x::TimeZoneInfo::AsFFI() const { + return reinterpret_cast(this); +} + +inline icu4x::capi::TimeZoneInfo* icu4x::TimeZoneInfo::AsFFI() { + return reinterpret_cast(this); +} + +inline const icu4x::TimeZoneInfo* icu4x::TimeZoneInfo::FromFFI(const icu4x::capi::TimeZoneInfo* ptr) { + return reinterpret_cast(ptr); +} + +inline icu4x::TimeZoneInfo* icu4x::TimeZoneInfo::FromFFI(icu4x::capi::TimeZoneInfo* ptr) { + return reinterpret_cast(ptr); +} + +inline void icu4x::TimeZoneInfo::operator delete(void* ptr) { + icu4x::capi::icu4x_TimeZoneInfo_destroy_mv1(reinterpret_cast(ptr)); +} + + +#endif // icu4x_TimeZoneInfo_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.d.hpp b/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.d.hpp deleted file mode 100644 index 98d6fb4c79f..00000000000 --- a/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.d.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef icu4x_ZoneOffsetCalculator_D_HPP -#define icu4x_ZoneOffsetCalculator_D_HPP - -#include -#include -#include -#include -#include -#include -#include "../diplomat_runtime.hpp" - -namespace icu4x { -namespace capi { struct DataProvider; } -class DataProvider; -namespace capi { struct ZoneOffsetCalculator; } -class ZoneOffsetCalculator; -class DataError; -} - - -namespace icu4x { -namespace capi { - struct ZoneOffsetCalculator; -} // namespace capi -} // namespace - -namespace icu4x { -class ZoneOffsetCalculator { -public: - - inline static diplomat::result, icu4x::DataError> create(const icu4x::DataProvider& provider); - - inline const icu4x::capi::ZoneOffsetCalculator* AsFFI() const; - inline icu4x::capi::ZoneOffsetCalculator* AsFFI(); - inline static const icu4x::ZoneOffsetCalculator* FromFFI(const icu4x::capi::ZoneOffsetCalculator* ptr); - inline static icu4x::ZoneOffsetCalculator* FromFFI(icu4x::capi::ZoneOffsetCalculator* ptr); - inline static void operator delete(void* ptr); -private: - ZoneOffsetCalculator() = delete; - ZoneOffsetCalculator(const icu4x::ZoneOffsetCalculator&) = delete; - ZoneOffsetCalculator(icu4x::ZoneOffsetCalculator&&) noexcept = delete; - ZoneOffsetCalculator operator=(const icu4x::ZoneOffsetCalculator&) = delete; - ZoneOffsetCalculator operator=(icu4x::ZoneOffsetCalculator&&) noexcept = delete; - static void operator delete[](void*, size_t) = delete; -}; - -} // namespace -#endif // icu4x_ZoneOffsetCalculator_D_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.hpp b/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.hpp deleted file mode 100644 index 782cd1aaadf..00000000000 --- a/ffi/capi/bindings/cpp/icu4x/ZoneOffsetCalculator.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef icu4x_ZoneOffsetCalculator_HPP -#define icu4x_ZoneOffsetCalculator_HPP - -#include "ZoneOffsetCalculator.d.hpp" - -#include -#include -#include -#include -#include -#include -#include "../diplomat_runtime.hpp" -#include "DataError.hpp" -#include "DataProvider.hpp" - - -namespace icu4x { -namespace capi { - extern "C" { - - typedef struct icu4x_ZoneOffsetCalculator_create_mv1_result {union {icu4x::capi::ZoneOffsetCalculator* ok; icu4x::capi::DataError err;}; bool is_ok;} icu4x_ZoneOffsetCalculator_create_mv1_result; - icu4x_ZoneOffsetCalculator_create_mv1_result icu4x_ZoneOffsetCalculator_create_mv1(const icu4x::capi::DataProvider* provider); - - - void icu4x_ZoneOffsetCalculator_destroy_mv1(ZoneOffsetCalculator* self); - - } // extern "C" -} // namespace capi -} // namespace - -inline diplomat::result, icu4x::DataError> icu4x::ZoneOffsetCalculator::create(const icu4x::DataProvider& provider) { - auto result = icu4x::capi::icu4x_ZoneOffsetCalculator_create_mv1(provider.AsFFI()); - return result.is_ok ? diplomat::result, icu4x::DataError>(diplomat::Ok>(std::unique_ptr(icu4x::ZoneOffsetCalculator::FromFFI(result.ok)))) : diplomat::result, icu4x::DataError>(diplomat::Err(icu4x::DataError::FromFFI(result.err))); -} - -inline const icu4x::capi::ZoneOffsetCalculator* icu4x::ZoneOffsetCalculator::AsFFI() const { - return reinterpret_cast(this); -} - -inline icu4x::capi::ZoneOffsetCalculator* icu4x::ZoneOffsetCalculator::AsFFI() { - return reinterpret_cast(this); -} - -inline const icu4x::ZoneOffsetCalculator* icu4x::ZoneOffsetCalculator::FromFFI(const icu4x::capi::ZoneOffsetCalculator* ptr) { - return reinterpret_cast(ptr); -} - -inline icu4x::ZoneOffsetCalculator* icu4x::ZoneOffsetCalculator::FromFFI(icu4x::capi::ZoneOffsetCalculator* ptr) { - return reinterpret_cast(ptr); -} - -inline void icu4x::ZoneOffsetCalculator::operator delete(void* ptr) { - icu4x::capi::icu4x_ZoneOffsetCalculator_destroy_mv1(reinterpret_cast(ptr)); -} - - -#endif // icu4x_ZoneOffsetCalculator_HPP diff --git a/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.d.hpp b/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.d.hpp index 54d0cfa3656..a5d7731ac96 100644 --- a/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.d.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.d.hpp @@ -10,8 +10,6 @@ #include "../diplomat_runtime.hpp" namespace icu4x { -namespace capi { struct CustomTimeZone; } -class CustomTimeZone; namespace capi { struct DataProvider; } class DataProvider; namespace capi { struct DateTime; } @@ -20,6 +18,8 @@ namespace capi { struct IsoDateTime; } class IsoDateTime; namespace capi { struct Locale; } class Locale; +namespace capi { struct TimeZoneInfo; } +class TimeZoneInfo; namespace capi { struct ZonedDateTimeFormatter; } class ZonedDateTimeFormatter; class DateTimeLength; @@ -39,9 +39,9 @@ class ZonedDateTimeFormatter { inline static diplomat::result, icu4x::Error> create_with_length(const icu4x::DataProvider& provider, const icu4x::Locale& locale, icu4x::DateTimeLength length); - inline diplomat::result format_datetime_with_custom_time_zone(const icu4x::DateTime& datetime, const icu4x::CustomTimeZone& time_zone) const; + inline diplomat::result format_datetime_with_custom_time_zone(const icu4x::DateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const; - inline diplomat::result format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::CustomTimeZone& time_zone) const; + inline diplomat::result format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const; inline const icu4x::capi::ZonedDateTimeFormatter* AsFFI() const; inline icu4x::capi::ZonedDateTimeFormatter* AsFFI(); diff --git a/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.hpp b/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.hpp index 81c53ffe446..6cb0ed80c62 100644 --- a/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.hpp +++ b/ffi/capi/bindings/cpp/icu4x/ZonedDateTimeFormatter.hpp @@ -10,13 +10,13 @@ #include #include #include "../diplomat_runtime.hpp" -#include "CustomTimeZone.hpp" #include "DataProvider.hpp" #include "DateTime.hpp" #include "DateTimeLength.hpp" #include "Error.hpp" #include "IsoDateTime.hpp" #include "Locale.hpp" +#include "TimeZoneInfo.hpp" namespace icu4x { @@ -27,10 +27,10 @@ namespace capi { icu4x_ZonedDateTimeFormatter_create_with_length_mv1_result icu4x_ZonedDateTimeFormatter_create_with_length_mv1(const icu4x::capi::DataProvider* provider, const icu4x::capi::Locale* locale, icu4x::capi::DateTimeLength length); typedef struct icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result {union { icu4x::capi::Error err;}; bool is_ok;} icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result; - icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(const icu4x::capi::ZonedDateTimeFormatter* self, const icu4x::capi::DateTime* datetime, const icu4x::capi::CustomTimeZone* time_zone, diplomat::capi::DiplomatWrite* write); + icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(const icu4x::capi::ZonedDateTimeFormatter* self, const icu4x::capi::DateTime* datetime, const icu4x::capi::TimeZoneInfo* time_zone, diplomat::capi::DiplomatWrite* write); typedef struct icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result {union { icu4x::capi::Error err;}; bool is_ok;} icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result; - icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const icu4x::capi::ZonedDateTimeFormatter* self, const icu4x::capi::IsoDateTime* datetime, const icu4x::capi::CustomTimeZone* time_zone, diplomat::capi::DiplomatWrite* write); + icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1_result icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(const icu4x::capi::ZonedDateTimeFormatter* self, const icu4x::capi::IsoDateTime* datetime, const icu4x::capi::TimeZoneInfo* time_zone, diplomat::capi::DiplomatWrite* write); void icu4x_ZonedDateTimeFormatter_destroy_mv1(ZonedDateTimeFormatter* self); @@ -46,7 +46,7 @@ inline diplomat::result, icu4x::E return result.is_ok ? diplomat::result, icu4x::Error>(diplomat::Ok>(std::unique_ptr(icu4x::ZonedDateTimeFormatter::FromFFI(result.ok)))) : diplomat::result, icu4x::Error>(diplomat::Err(icu4x::Error::FromFFI(result.err))); } -inline diplomat::result icu4x::ZonedDateTimeFormatter::format_datetime_with_custom_time_zone(const icu4x::DateTime& datetime, const icu4x::CustomTimeZone& time_zone) const { +inline diplomat::result icu4x::ZonedDateTimeFormatter::format_datetime_with_custom_time_zone(const icu4x::DateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); auto result = icu4x::capi::icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(this->AsFFI(), @@ -56,7 +56,7 @@ inline diplomat::result icu4x::ZonedDateTimeFormatter return result.is_ok ? diplomat::result(diplomat::Ok(std::move(output))) : diplomat::result(diplomat::Err(icu4x::Error::FromFFI(result.err))); } -inline diplomat::result icu4x::ZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::CustomTimeZone& time_zone) const { +inline diplomat::result icu4x::ZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const icu4x::IsoDateTime& datetime, const icu4x::TimeZoneInfo& time_zone) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); auto result = icu4x::capi::icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(this->AsFFI(), diff --git a/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart b/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart index 382b5200874..2a5a80b01eb 100644 --- a/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart @@ -38,8 +38,8 @@ final class GregorianZonedDateTimeFormatter implements ffi.Finalizable { return GregorianZonedDateTimeFormatter._fromFfi(result.union.ok, []); } - /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. - String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, CustomTimeZone timeZone) { + /// Formats a [`IsoDateTime`] and [`TimeZoneInfo`] to a string. + String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, TimeZoneInfo timeZone) { final write = _Write(); _icu4x_GregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(_ffi, datetime._ffi, timeZone._ffi, write._ffi); return write.finalize(); diff --git a/ffi/capi/bindings/dart/MetazoneCalculator.g.dart b/ffi/capi/bindings/dart/MetazoneCalculator.g.dart deleted file mode 100644 index 9cf67abeb41..00000000000 --- a/ffi/capi/bindings/dart/MetazoneCalculator.g.dart +++ /dev/null @@ -1,51 +0,0 @@ -// generated by diplomat-tool - -part of 'lib.g.dart'; - -/// An object capable of computing the metazone from a timezone. -/// -/// This can be used via `maybe_calculate_metazone()` on [`CustomTimeZone`]. -/// -/// [`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -/// -/// See the [Rust documentation for `MetazoneCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html) for more information. -final class MetazoneCalculator implements ffi.Finalizable { - final ffi.Pointer _ffi; - - // These are "used" in the sense that they keep dependencies alive - // ignore: unused_field - final core.List _selfEdge; - - // This takes in a list of lifetime edges (including for &self borrows) - // corresponding to data this may borrow from. These should be flat arrays containing - // references to objects, and this object will hold on to them to keep them alive and - // maintain borrow validity. - MetazoneCalculator._fromFfi(this._ffi, this._selfEdge) { - if (_selfEdge.isEmpty) { - _finalizer.attach(this, _ffi.cast()); - } - } - - static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_MetazoneCalculator_destroy_mv1)); - - /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.new) for more information. - /// - /// Throws [DataError] on failure. - factory MetazoneCalculator(DataProvider provider) { - final result = _icu4x_MetazoneCalculator_create_mv1(provider._ffi); - if (!result.isOk) { - throw DataError.values[result.union.err]; - } - return MetazoneCalculator._fromFfi(result.union.ok, []); - } -} - -@meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_MetazoneCalculator_destroy_mv1') -// ignore: non_constant_identifier_names -external void _icu4x_MetazoneCalculator_destroy_mv1(ffi.Pointer self); - -@meta.RecordUse() -@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_MetazoneCalculator_create_mv1') -// ignore: non_constant_identifier_names -external _ResultOpaqueInt32 _icu4x_MetazoneCalculator_create_mv1(ffi.Pointer provider); diff --git a/ffi/capi/bindings/dart/CustomTimeZone.g.dart b/ffi/capi/bindings/dart/TimeZoneInfo.g.dart similarity index 53% rename from ffi/capi/bindings/dart/CustomTimeZone.g.dart rename to ffi/capi/bindings/dart/TimeZoneInfo.g.dart index 967766c58ed..5778e56a053 100644 --- a/ffi/capi/bindings/dart/CustomTimeZone.g.dart +++ b/ffi/capi/bindings/dart/TimeZoneInfo.g.dart @@ -2,8 +2,8 @@ part of 'lib.g.dart'; -/// See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. -final class CustomTimeZone implements ffi.Finalizable { +/// See the [Rust documentation for `TimeZoneInfo`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html) for more information. +final class TimeZoneInfo implements ffi.Finalizable { final ffi.Pointer _ffi; // These are "used" in the sense that they keep dependencies alive @@ -14,37 +14,28 @@ final class CustomTimeZone implements ffi.Finalizable { // corresponding to data this may borrow from. These should be flat arrays containing // references to objects, and this object will hold on to them to keep them alive and // maintain borrow validity. - CustomTimeZone._fromFfi(this._ffi, this._selfEdge) { + TimeZoneInfo._fromFfi(this._ffi, this._selfEdge) { if (_selfEdge.isEmpty) { _finalizer.attach(this, _ffi.cast()); } } - static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_CustomTimeZone_destroy_mv1)); - - /// Creates a time zone from an offset string. - /// - /// See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.from_str) for more information. - factory CustomTimeZone.fromString(String s) { - final temp = _FinalizedArena(); - final result = _icu4x_CustomTimeZone_from_string_mv1(s._utf8AllocIn(temp.arena)); - return CustomTimeZone._fromFfi(result, []); - } + static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_TimeZoneInfo_destroy_mv1)); /// Creates a time zone with no information. /// - /// See the [Rust documentation for `unknown`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.unknown) for more information. - factory CustomTimeZone.unknown() { - final result = _icu4x_CustomTimeZone_unknown_mv1(); - return CustomTimeZone._fromFfi(result, []); + /// See the [Rust documentation for `unknown`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#method.unknown) for more information. + factory TimeZoneInfo() { + final result = _icu4x_TimeZoneInfo_unknown_mv1(); + return TimeZoneInfo._fromFfi(result, []); } /// Creates a time zone for UTC (Coordinated Universal Time). /// - /// See the [Rust documentation for `utc`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.utc) for more information. - factory CustomTimeZone.utc() { - final result = _icu4x_CustomTimeZone_utc_mv1(); - return CustomTimeZone._fromFfi(result, []); + /// See the [Rust documentation for `utc`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#method.utc) for more information. + factory TimeZoneInfo.utc() { + final result = _icu4x_TimeZoneInfo_utc_mv1(); + return TimeZoneInfo._fromFfi(result, []); } /// Sets the `offset` field from offset seconds. @@ -57,7 +48,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [TimeZoneInvalidOffsetError] on failure. void trySetOffsetSeconds(int offsetSeconds) { - final result = _icu4x_CustomTimeZone_try_set_offset_seconds_mv1(_ffi, offsetSeconds); + final result = _icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(_ffi, offsetSeconds); if (!result.isOk) { throw TimeZoneInvalidOffsetError(); } @@ -68,14 +59,28 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `from_eighths_of_hour`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.from_eighths_of_hour) for more information. void setOffsetEighthsOfHour(int offsetEighthsOfHour) { - _icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(_ffi, offsetEighthsOfHour); + _icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(_ffi, offsetEighthsOfHour); + } + + /// Sets the `offset` field from a string. + /// + /// See the [Rust documentation for `try_from_str`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.try_from_str) for more information. + /// + /// Throws [TimeZoneInvalidOffsetError] on failure. + void trySetOffsetStr(String offset) { + final temp = _FinalizedArena(); + final result = _icu4x_TimeZoneInfo_try_set_offset_str_mv1(_ffi, offset._utf8AllocIn(temp.arena)); + if (!result.isOk) { + throw TimeZoneInvalidOffsetError(); + } + } /// Gets the `offset` field from offset as eighths of an hour. /// /// See the [Rust documentation for `to_eighths_of_hour`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.to_eighths_of_hour) for more information. int? offsetEighthsOfHour() { - final result = _icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(_ffi); if (!result.isOk) { return null; } @@ -88,7 +93,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html) void clearOffset() { - _icu4x_CustomTimeZone_clear_offset_mv1(_ffi); + _icu4x_TimeZoneInfo_clear_offset_mv1(_ffi); } /// Returns the value of the `offset` field as offset seconds. @@ -99,7 +104,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html) int? get offsetSeconds { - final result = _icu4x_CustomTimeZone_offset_seconds_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_offset_seconds_mv1(_ffi); if (!result.isOk) { return null; } @@ -112,7 +117,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `is_positive`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.is_positive) for more information. bool? get isOffsetPositive { - final result = _icu4x_CustomTimeZone_is_offset_positive_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_is_offset_positive_mv1(_ffi); if (!result.isOk) { return null; } @@ -125,7 +130,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `is_zero`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.is_zero) for more information. bool? get isOffsetZero { - final result = _icu4x_CustomTimeZone_is_offset_zero_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_is_offset_zero_mv1(_ffi); if (!result.isOk) { return null; } @@ -138,7 +143,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `hours_part`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.hours_part) for more information. int? get offsetHoursPart { - final result = _icu4x_CustomTimeZone_offset_hours_part_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_offset_hours_part_mv1(_ffi); if (!result.isOk) { return null; } @@ -151,7 +156,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `minutes_part`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.minutes_part) for more information. int? get offsetMinutesPart { - final result = _icu4x_CustomTimeZone_offset_minutes_part_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_offset_minutes_part_mv1(_ffi); if (!result.isOk) { return null; } @@ -164,7 +169,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `seconds_part`](https://docs.rs/icu/latest/icu/timezone/struct.UtcOffset.html#method.seconds_part) for more information. int? get offsetSecondsPart { - final result = _icu4x_CustomTimeZone_offset_seconds_part_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_offset_seconds_part_mv1(_ffi); if (!result.isOk) { return null; } @@ -175,59 +180,31 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Errors if the string is not a valid BCP-47 time zone ID. /// - /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.time_zone_id) for more information. /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) void setTimeZoneId(String id) { final temp = _FinalizedArena(); - _icu4x_CustomTimeZone_set_time_zone_id_mv1(_ffi, id._utf8AllocIn(temp.arena)); + _icu4x_TimeZoneInfo_set_time_zone_id_mv1(_ffi, id._utf8AllocIn(temp.arena)); } /// Sets the `time_zone_id` field from an IANA string by looking up /// the corresponding BCP-47 string. void setIanaTimeZoneId(TimeZoneIdMapper mapper, String id) { final temp = _FinalizedArena(); - _icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(_ffi, mapper._ffi, id._utf8AllocIn(temp.arena)); + _icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(_ffi, mapper._ffi, id._utf8AllocIn(temp.arena)); } /// Writes the value of the `time_zone_id` field as a string. /// /// Returns null if the `time_zone_id` field is empty. /// - /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.time_zone_id) for more information. /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) String get timeZoneId { final write = _Write(); - _icu4x_CustomTimeZone_time_zone_id_mv1(_ffi, write._ffi); - return write.finalize(); - } - - /// Sets the `metazone_id` field from a string. - /// - /// Returns null if the string is not a valid BCP-47 metazone ID. - /// - /// See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. - /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) - void setMetazoneId(String id) { - final temp = _FinalizedArena(); - _icu4x_CustomTimeZone_set_metazone_id_mv1(_ffi, id._utf8AllocIn(temp.arena)); - } - - /// Writes the value of the `metazone_id` field as a string. - /// - /// Returns null if the `metazone_id` field is empty or unresolved. - /// - /// See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. - /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) - String? get metazoneId { - final write = _Write(); - final result = _icu4x_CustomTimeZone_metazone_id_mv1(_ffi, write._ffi); - if (!result.isOk) { - return null; - } + _icu4x_TimeZoneInfo_time_zone_id_mv1(_ffi, write._ffi); return write.finalize(); } @@ -235,34 +212,34 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Returns null if the string is not a valid zone variant. /// - /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) for more information. /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) bool trySetZoneVariant(String id) { final temp = _FinalizedArena(); - final result = _icu4x_CustomTimeZone_try_set_zone_variant_mv1(_ffi, id._utf8AllocIn(temp.arena)); + final result = _icu4x_TimeZoneInfo_try_set_zone_variant_mv1(_ffi, id._utf8AllocIn(temp.arena)); return result.isOk; } /// Clears the `zone_variant` field. /// - /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) for more information. /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) void clearZoneVariant() { - _icu4x_CustomTimeZone_clear_zone_variant_mv1(_ffi); + _icu4x_TimeZoneInfo_clear_zone_variant_mv1(_ffi); } /// Writes the value of the `zone_variant` field as a string. /// /// Returns null if the `zone_variant` field is empty. /// - /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) for more information. /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) String? get zoneVariant { final write = _Write(); - final result = _icu4x_CustomTimeZone_zone_variant_mv1(_ffi, write._ffi); + final result = _icu4x_TimeZoneInfo_zone_variant_mv1(_ffi, write._ffi); if (!result.isOk) { return null; } @@ -274,9 +251,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) void setStandardTime() { - _icu4x_CustomTimeZone_set_standard_time_mv1(_ffi); + _icu4x_TimeZoneInfo_set_standard_time_mv1(_ffi); } /// Sets the `zone_variant` field to "daylight" time, which may or may @@ -284,9 +261,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) void setDaylightTime() { - _icu4x_CustomTimeZone_set_daylight_time_mv1(_ffi); + _icu4x_TimeZoneInfo_set_daylight_time_mv1(_ffi); } /// Returns whether the `zone_variant` field is standard time. @@ -295,9 +272,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) bool? get isStandardTime { - final result = _icu4x_CustomTimeZone_is_standard_time_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_is_standard_time_mv1(_ffi); if (!result.isOk) { return null; } @@ -310,170 +287,169 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.zone_variant) bool? get isDaylightTime { - final result = _icu4x_CustomTimeZone_is_daylight_time_mv1(_ffi); + final result = _icu4x_TimeZoneInfo_is_daylight_time_mv1(_ffi); if (!result.isOk) { return null; } return result.union.ok; } - /// Sets the metazone based on the time zone and the local timestamp. + /// Sets the `local_time` field. /// - /// See the [Rust documentation for `maybe_calculate_metazone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_metazone) for more information. - /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.compute_metazone_from_time_zone) - void maybeCalculateMetazone(MetazoneCalculator metazoneCalculator, IsoDateTime localDatetime) { - _icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(_ffi, metazoneCalculator._ffi, localDatetime._ffi); + /// See the [Rust documentation for `local_time`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.local_time) for more information. + void setLocalTime(IsoDateTime datetime) { + _icu4x_TimeZoneInfo_set_local_time_mv1(_ffi, datetime._ffi); } - /// Sets the zone variant based on the time zone and the local timestamp. + /// Clears the `local_time` field. /// - /// See the [Rust documentation for `maybe_calculate_zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_zone_variant) for more information. + /// See the [Rust documentation for `local_time`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.local_time) for more information. + void clearLocalTime() { + _icu4x_TimeZoneInfo_clear_local_time_mv1(_ffi); + } + + /// Returns a copy of the `local_time` field. /// - /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneOffsetCalculator.html#method.compute_offsets_from_time_zone) - void maybeCalculateZoneVariant(ZoneOffsetCalculator zoneOffsetCalculator, IsoDateTime localDatetime) { - _icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(_ffi, zoneOffsetCalculator._ffi, localDatetime._ffi); + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html#structfield.local_time) + IsoDateTime? getLocalTime() { + final result = _icu4x_TimeZoneInfo_get_local_time_mv1(_ffi); + return result.address == 0 ? null : IsoDateTime._fromFfi(result, []); } } @meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_destroy_mv1') -// ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_destroy_mv1(ffi.Pointer self); - -@meta.RecordUse() -@ffi.Native Function(_SliceUtf8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_from_string_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_destroy_mv1') // ignore: non_constant_identifier_names -external ffi.Pointer _icu4x_CustomTimeZone_from_string_mv1(_SliceUtf8 s); +external void _icu4x_TimeZoneInfo_destroy_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native Function()>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_unknown_mv1') +@ffi.Native Function()>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_unknown_mv1') // ignore: non_constant_identifier_names -external ffi.Pointer _icu4x_CustomTimeZone_unknown_mv1(); +external ffi.Pointer _icu4x_TimeZoneInfo_unknown_mv1(); @meta.RecordUse() -@ffi.Native Function()>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_utc_mv1') +@ffi.Native Function()>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_utc_mv1') // ignore: non_constant_identifier_names -external ffi.Pointer _icu4x_CustomTimeZone_utc_mv1(); +external ffi.Pointer _icu4x_TimeZoneInfo_utc_mv1(); @meta.RecordUse() -@ffi.Native<_ResultVoidTimeZoneInvalidOffsetErrorFfi Function(ffi.Pointer, ffi.Int32)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_try_set_offset_seconds_mv1') +@ffi.Native<_ResultVoidTimeZoneInvalidOffsetErrorFfi Function(ffi.Pointer, ffi.Int32)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_try_set_offset_seconds_mv1') // ignore: non_constant_identifier_names -external _ResultVoidTimeZoneInvalidOffsetErrorFfi _icu4x_CustomTimeZone_try_set_offset_seconds_mv1(ffi.Pointer self, int offsetSeconds); +external _ResultVoidTimeZoneInvalidOffsetErrorFfi _icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(ffi.Pointer self, int offsetSeconds); @meta.RecordUse() -@ffi.Native, ffi.Int8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1') +@ffi.Native, ffi.Int8)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(ffi.Pointer self, int offsetEighthsOfHour); +external void _icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(ffi.Pointer self, int offsetEighthsOfHour); @meta.RecordUse() -@ffi.Native<_ResultInt8Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_offset_eighths_of_hour_mv1') +@ffi.Native<_ResultVoidTimeZoneInvalidOffsetErrorFfi Function(ffi.Pointer, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_try_set_offset_str_mv1') // ignore: non_constant_identifier_names -external _ResultInt8Void _icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(ffi.Pointer self); +external _ResultVoidTimeZoneInvalidOffsetErrorFfi _icu4x_TimeZoneInfo_try_set_offset_str_mv1(ffi.Pointer self, _SliceUtf8 offset); @meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_clear_offset_mv1') +@ffi.Native<_ResultInt8Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_clear_offset_mv1(ffi.Pointer self); +external _ResultInt8Void _icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultInt32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_offset_seconds_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_clear_offset_mv1') // ignore: non_constant_identifier_names -external _ResultInt32Void _icu4x_CustomTimeZone_offset_seconds_mv1(ffi.Pointer self); +external void _icu4x_TimeZoneInfo_clear_offset_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_is_offset_positive_mv1') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_seconds_mv1') // ignore: non_constant_identifier_names -external _ResultBoolVoid _icu4x_CustomTimeZone_is_offset_positive_mv1(ffi.Pointer self); +external _ResultInt32Void _icu4x_TimeZoneInfo_offset_seconds_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_is_offset_zero_mv1') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_is_offset_positive_mv1') // ignore: non_constant_identifier_names -external _ResultBoolVoid _icu4x_CustomTimeZone_is_offset_zero_mv1(ffi.Pointer self); +external _ResultBoolVoid _icu4x_TimeZoneInfo_is_offset_positive_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultInt32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_offset_hours_part_mv1') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_is_offset_zero_mv1') // ignore: non_constant_identifier_names -external _ResultInt32Void _icu4x_CustomTimeZone_offset_hours_part_mv1(ffi.Pointer self); +external _ResultBoolVoid _icu4x_TimeZoneInfo_is_offset_zero_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultUint32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_offset_minutes_part_mv1') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_hours_part_mv1') // ignore: non_constant_identifier_names -external _ResultUint32Void _icu4x_CustomTimeZone_offset_minutes_part_mv1(ffi.Pointer self); +external _ResultInt32Void _icu4x_TimeZoneInfo_offset_hours_part_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultUint32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_offset_seconds_part_mv1') +@ffi.Native<_ResultUint32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_minutes_part_mv1') // ignore: non_constant_identifier_names -external _ResultUint32Void _icu4x_CustomTimeZone_offset_seconds_part_mv1(ffi.Pointer self); +external _ResultUint32Void _icu4x_TimeZoneInfo_offset_minutes_part_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_time_zone_id_mv1') +@ffi.Native<_ResultUint32Void Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_offset_seconds_part_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_time_zone_id_mv1(ffi.Pointer self, _SliceUtf8 id); +external _ResultUint32Void _icu4x_TimeZoneInfo_offset_seconds_part_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native, ffi.Pointer, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_iana_time_zone_id_mv1') +@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_time_zone_id_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(ffi.Pointer self, ffi.Pointer mapper, _SliceUtf8 id); +external void _icu4x_TimeZoneInfo_set_time_zone_id_mv1(ffi.Pointer self, _SliceUtf8 id); @meta.RecordUse() -@ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_time_zone_id_mv1') +@ffi.Native, ffi.Pointer, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_time_zone_id_mv1(ffi.Pointer self, ffi.Pointer write); +external void _icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(ffi.Pointer self, ffi.Pointer mapper, _SliceUtf8 id); @meta.RecordUse() -@ffi.Native, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_metazone_id_mv1') +@ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_time_zone_id_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_metazone_id_mv1(ffi.Pointer self, _SliceUtf8 id); +external void _icu4x_TimeZoneInfo_time_zone_id_mv1(ffi.Pointer self, ffi.Pointer write); @meta.RecordUse() -@ffi.Native<_ResultVoidVoid Function(ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_metazone_id_mv1') +@ffi.Native<_ResultVoidVoid Function(ffi.Pointer, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_try_set_zone_variant_mv1') // ignore: non_constant_identifier_names -external _ResultVoidVoid _icu4x_CustomTimeZone_metazone_id_mv1(ffi.Pointer self, ffi.Pointer write); +external _ResultVoidVoid _icu4x_TimeZoneInfo_try_set_zone_variant_mv1(ffi.Pointer self, _SliceUtf8 id); @meta.RecordUse() -@ffi.Native<_ResultVoidVoid Function(ffi.Pointer, _SliceUtf8)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_try_set_zone_variant_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_clear_zone_variant_mv1') // ignore: non_constant_identifier_names -external _ResultVoidVoid _icu4x_CustomTimeZone_try_set_zone_variant_mv1(ffi.Pointer self, _SliceUtf8 id); +external void _icu4x_TimeZoneInfo_clear_zone_variant_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_clear_zone_variant_mv1') +@ffi.Native<_ResultVoidVoid Function(ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_zone_variant_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_clear_zone_variant_mv1(ffi.Pointer self); +external _ResultVoidVoid _icu4x_TimeZoneInfo_zone_variant_mv1(ffi.Pointer self, ffi.Pointer write); @meta.RecordUse() -@ffi.Native<_ResultVoidVoid Function(ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_zone_variant_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_standard_time_mv1') // ignore: non_constant_identifier_names -external _ResultVoidVoid _icu4x_CustomTimeZone_zone_variant_mv1(ffi.Pointer self, ffi.Pointer write); +external void _icu4x_TimeZoneInfo_set_standard_time_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_standard_time_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_daylight_time_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_standard_time_mv1(ffi.Pointer self); +external void _icu4x_TimeZoneInfo_set_daylight_time_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_set_daylight_time_mv1') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_is_standard_time_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_set_daylight_time_mv1(ffi.Pointer self); +external _ResultBoolVoid _icu4x_TimeZoneInfo_is_standard_time_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_is_standard_time_mv1') +@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_is_daylight_time_mv1') // ignore: non_constant_identifier_names -external _ResultBoolVoid _icu4x_CustomTimeZone_is_standard_time_mv1(ffi.Pointer self); +external _ResultBoolVoid _icu4x_TimeZoneInfo_is_daylight_time_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native<_ResultBoolVoid Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_is_daylight_time_mv1') +@ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_set_local_time_mv1') // ignore: non_constant_identifier_names -external _ResultBoolVoid _icu4x_CustomTimeZone_is_daylight_time_mv1(ffi.Pointer self); +external void _icu4x_TimeZoneInfo_set_local_time_mv1(ffi.Pointer self, ffi.Pointer datetime); @meta.RecordUse() -@ffi.Native, ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_maybe_calculate_metazone_mv1') +@ffi.Native)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_clear_local_time_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(ffi.Pointer self, ffi.Pointer metazoneCalculator, ffi.Pointer localDatetime); +external void _icu4x_TimeZoneInfo_clear_local_time_mv1(ffi.Pointer self); @meta.RecordUse() -@ffi.Native, ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1') +@ffi.Native Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_TimeZoneInfo_get_local_time_mv1') // ignore: non_constant_identifier_names -external void _icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(ffi.Pointer self, ffi.Pointer zoneOffsetCalculator, ffi.Pointer localDatetime); +external ffi.Pointer _icu4x_TimeZoneInfo_get_local_time_mv1(ffi.Pointer self); diff --git a/ffi/capi/bindings/dart/ZoneOffsetCalculator.g.dart b/ffi/capi/bindings/dart/ZoneOffsetCalculator.g.dart deleted file mode 100644 index cd5a7f39724..00000000000 --- a/ffi/capi/bindings/dart/ZoneOffsetCalculator.g.dart +++ /dev/null @@ -1,51 +0,0 @@ -// generated by diplomat-tool - -part of 'lib.g.dart'; - -/// An object capable of computing UTC offsets from a timezone. -/// -/// This can be used via `maybe_calculate_zone_variant()` on [`CustomTimeZone`]. -/// -/// [`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -/// -/// See the [Rust documentation for `ZoneOffsetCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneOffsetCalculator.html) for more information. -final class ZoneOffsetCalculator implements ffi.Finalizable { - final ffi.Pointer _ffi; - - // These are "used" in the sense that they keep dependencies alive - // ignore: unused_field - final core.List _selfEdge; - - // This takes in a list of lifetime edges (including for &self borrows) - // corresponding to data this may borrow from. These should be flat arrays containing - // references to objects, and this object will hold on to them to keep them alive and - // maintain borrow validity. - ZoneOffsetCalculator._fromFfi(this._ffi, this._selfEdge) { - if (_selfEdge.isEmpty) { - _finalizer.attach(this, _ffi.cast()); - } - } - - static final _finalizer = ffi.NativeFinalizer(ffi.Native.addressOf(_icu4x_ZoneOffsetCalculator_destroy_mv1)); - - /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneOffsetCalculator.html#method.new) for more information. - /// - /// Throws [DataError] on failure. - factory ZoneOffsetCalculator(DataProvider provider) { - final result = _icu4x_ZoneOffsetCalculator_create_mv1(provider._ffi); - if (!result.isOk) { - throw DataError.values[result.union.err]; - } - return ZoneOffsetCalculator._fromFfi(result.union.ok, []); - } -} - -@meta.RecordUse() -@ffi.Native)>(isLeaf: true, symbol: 'icu4x_ZoneOffsetCalculator_destroy_mv1') -// ignore: non_constant_identifier_names -external void _icu4x_ZoneOffsetCalculator_destroy_mv1(ffi.Pointer self); - -@meta.RecordUse() -@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>(isLeaf: true, symbol: 'icu4x_ZoneOffsetCalculator_create_mv1') -// ignore: non_constant_identifier_names -external _ResultOpaqueInt32 _icu4x_ZoneOffsetCalculator_create_mv1(ffi.Pointer provider); diff --git a/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart b/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart index a25f8aa6ae4..48204f3d140 100644 --- a/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart @@ -38,10 +38,10 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { return ZonedDateTimeFormatter._fromFfi(result.union.ok, []); } - /// Formats a [`DateTime`] and [`CustomTimeZone`] to a string. + /// Formats a [`DateTime`] and [`TimeZoneInfo`] to a string. /// /// Throws [Error] on failure. - String formatDatetimeWithCustomTimeZone(DateTime datetime, CustomTimeZone timeZone) { + String formatDatetimeWithCustomTimeZone(DateTime datetime, TimeZoneInfo timeZone) { final write = _Write(); final result = _icu4x_ZonedDateTimeFormatter_format_datetime_with_custom_time_zone_mv1(_ffi, datetime._ffi, timeZone._ffi, write._ffi); if (!result.isOk) { @@ -50,10 +50,10 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { return write.finalize(); } - /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. + /// Formats a [`IsoDateTime`] and [`TimeZoneInfo`] to a string. /// /// Throws [Error] on failure. - String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, CustomTimeZone timeZone) { + String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, TimeZoneInfo timeZone) { final write = _Write(); final result = _icu4x_ZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone_mv1(_ffi, datetime._ffi, timeZone._ffi, write._ffi); if (!result.isOk) { diff --git a/ffi/capi/bindings/dart/lib.g.dart b/ffi/capi/bindings/dart/lib.g.dart index 9e90fdc7f1f..4329913216b 100644 --- a/ffi/capi/bindings/dart/lib.g.dart +++ b/ffi/capi/bindings/dart/lib.g.dart @@ -40,7 +40,6 @@ part 'CollatorOptions.g.dart'; part 'CollatorResolvedOptions.g.dart'; part 'CollatorStrength.g.dart'; part 'ComposingNormalizer.g.dart'; -part 'CustomTimeZone.g.dart'; part 'DataError.g.dart'; part 'DataProvider.g.dart'; part 'Date.g.dart'; @@ -102,7 +101,6 @@ part 'LocaleParseError.g.dart'; part 'Logger.g.dart'; part 'MeasureUnit.g.dart'; part 'MeasureUnitParser.g.dart'; -part 'MetazoneCalculator.g.dart'; part 'PluralCategories.g.dart'; part 'PluralCategory.g.dart'; part 'PluralOperands.g.dart'; @@ -122,6 +120,7 @@ part 'Time.g.dart'; part 'TimeFormatter.g.dart'; part 'TimeZoneIdMapper.g.dart'; part 'TimeZoneIdMapperWithFastCanonicalization.g.dart'; +part 'TimeZoneInfo.g.dart'; part 'TimeZoneInvalidOffsetError.g.dart'; part 'TitlecaseMapper.g.dart'; part 'TitlecaseOptions.g.dart'; @@ -137,7 +136,6 @@ part 'WordBreakIteratorLatin1.g.dart'; part 'WordBreakIteratorUtf16.g.dart'; part 'WordBreakIteratorUtf8.g.dart'; part 'WordSegmenter.g.dart'; -part 'ZoneOffsetCalculator.g.dart'; part 'ZonedDateTimeFormatter.g.dart'; /// A [Rune] is a Unicode code point, such as `a`, or `💡`. diff --git a/ffi/capi/bindings/demo_gen/CustomTimeZone.d.ts b/ffi/capi/bindings/demo_gen/CustomTimeZone.d.ts deleted file mode 100644 index b8b8b23f7a7..00000000000 --- a/ffi/capi/bindings/demo_gen/CustomTimeZone.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { CustomTimeZone } from "icu4x" -export function timeZoneId(s: string); -export function metazoneId(s: string); -export function zoneVariant(s: string); diff --git a/ffi/capi/bindings/demo_gen/CustomTimeZone.mjs b/ffi/capi/bindings/demo_gen/CustomTimeZone.mjs deleted file mode 100644 index 2da8a07ab95..00000000000 --- a/ffi/capi/bindings/demo_gen/CustomTimeZone.mjs +++ /dev/null @@ -1,43 +0,0 @@ -import { CustomTimeZone } from "icu4x" -export function timeZoneId() { - var terminusArgs = arguments; - return (function (...args) { return args[0].timeZoneId }).apply( - null, - [ - CustomTimeZone.fromString.apply( - null, - [ - terminusArgs[0] - ] - ) - ] - ); -} -export function metazoneId() { - var terminusArgs = arguments; - return (function (...args) { return args[0].metazoneId }).apply( - null, - [ - CustomTimeZone.fromString.apply( - null, - [ - terminusArgs[0] - ] - ) - ] - ); -} -export function zoneVariant() { - var terminusArgs = arguments; - return (function (...args) { return args[0].zoneVariant }).apply( - null, - [ - CustomTimeZone.fromString.apply( - null, - [ - terminusArgs[0] - ] - ) - ] - ); -} diff --git a/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.d.ts b/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.d.ts index 05087016505..ce6d9c32efb 100644 --- a/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.d.ts +++ b/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.d.ts @@ -1,6 +1,6 @@ -import { CustomTimeZone } from "icu4x" import { DataProvider } from "icu4x" import { GregorianZonedDateTimeFormatter } from "icu4x" import { IsoDateTime } from "icu4x" import { Locale } from "icu4x" -export function formatIsoDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number, s: string); +import { TimeZoneInfo } from "icu4x" +export function formatIsoDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number); diff --git a/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.mjs b/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.mjs index 9994158cf9d..b7ac7431098 100644 --- a/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.mjs +++ b/ffi/capi/bindings/demo_gen/GregorianZonedDateTimeFormatter.mjs @@ -1,8 +1,8 @@ -import { CustomTimeZone } from "icu4x" import { DataProvider } from "icu4x" import { GregorianZonedDateTimeFormatter } from "icu4x" import { IsoDateTime } from "icu4x" import { Locale } from "icu4x" +import { TimeZoneInfo } from "icu4x" export function formatIsoDatetimeWithCustomTimeZone() { var terminusArgs = arguments; return (function (...args) { return args[0].formatIsoDatetimeWithCustomTimeZone(...args.slice(1)) }).apply( @@ -37,10 +37,9 @@ export function formatIsoDatetimeWithCustomTimeZone() { terminusArgs[8] ] ), - CustomTimeZone.fromString.apply( + TimeZoneInfo.unknown.apply( null, [ - terminusArgs[9] ] ) ] diff --git a/ffi/capi/bindings/demo_gen/TimeZoneInfo.d.ts b/ffi/capi/bindings/demo_gen/TimeZoneInfo.d.ts new file mode 100644 index 00000000000..e7313f93520 --- /dev/null +++ b/ffi/capi/bindings/demo_gen/TimeZoneInfo.d.ts @@ -0,0 +1,3 @@ +import { TimeZoneInfo } from "icu4x" +export function timeZoneId(); +export function zoneVariant(); diff --git a/ffi/capi/bindings/demo_gen/TimeZoneInfo.mjs b/ffi/capi/bindings/demo_gen/TimeZoneInfo.mjs new file mode 100644 index 00000000000..89afa48e102 --- /dev/null +++ b/ffi/capi/bindings/demo_gen/TimeZoneInfo.mjs @@ -0,0 +1,27 @@ +import { TimeZoneInfo } from "icu4x" +export function timeZoneId() { + var terminusArgs = arguments; + return (function (...args) { return args[0].timeZoneId }).apply( + null, + [ + TimeZoneInfo.unknown.apply( + null, + [ + ] + ) + ] + ); +} +export function zoneVariant() { + var terminusArgs = arguments; + return (function (...args) { return args[0].zoneVariant }).apply( + null, + [ + TimeZoneInfo.unknown.apply( + null, + [ + ] + ) + ] + ); +} diff --git a/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.d.ts b/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.d.ts index fcfdebf0046..941e69b0e28 100644 --- a/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.d.ts +++ b/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.d.ts @@ -1,9 +1,9 @@ import { Calendar } from "icu4x" -import { CustomTimeZone } from "icu4x" import { DataProvider } from "icu4x" import { DateTime } from "icu4x" import { IsoDateTime } from "icu4x" import { Locale } from "icu4x" +import { TimeZoneInfo } from "icu4x" import { ZonedDateTimeFormatter } from "icu4x" -export function formatDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number, name: string, s: string); -export function formatIsoDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number, s: string); +export function formatDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number, name: string); +export function formatIsoDatetimeWithCustomTimeZone(name: string, length: DateTimeLength, year: number, month: number, day: number, hour: number, minute: number, second: number, nanosecond: number); diff --git a/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.mjs b/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.mjs index 1a0fa56a68e..f1176cae38d 100644 --- a/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.mjs +++ b/ffi/capi/bindings/demo_gen/ZonedDateTimeFormatter.mjs @@ -1,9 +1,9 @@ import { Calendar } from "icu4x" -import { CustomTimeZone } from "icu4x" import { DataProvider } from "icu4x" import { DateTime } from "icu4x" import { IsoDateTime } from "icu4x" import { Locale } from "icu4x" +import { TimeZoneInfo } from "icu4x" import { ZonedDateTimeFormatter } from "icu4x" export function formatDatetimeWithCustomTimeZone() { var terminusArgs = arguments; @@ -55,10 +55,9 @@ export function formatDatetimeWithCustomTimeZone() { ) ] ), - CustomTimeZone.fromString.apply( + TimeZoneInfo.unknown.apply( null, [ - terminusArgs[10] ] ) ] @@ -98,10 +97,9 @@ export function formatIsoDatetimeWithCustomTimeZone() { terminusArgs[8] ] ), - CustomTimeZone.fromString.apply( + TimeZoneInfo.unknown.apply( null, [ - terminusArgs[9] ] ) ] diff --git a/ffi/capi/bindings/demo_gen/index.mjs b/ffi/capi/bindings/demo_gen/index.mjs index 439f06d6836..58453bcc041 100644 --- a/ffi/capi/bindings/demo_gen/index.mjs +++ b/ffi/capi/bindings/demo_gen/index.mjs @@ -29,8 +29,8 @@ import * as ComposingNormalizerDemo from "./ComposingNormalizer.mjs"; export * as ComposingNormalizerDemo from "./ComposingNormalizer.mjs"; import * as DecomposingNormalizerDemo from "./DecomposingNormalizer.mjs"; export * as DecomposingNormalizerDemo from "./DecomposingNormalizer.mjs"; -import * as CustomTimeZoneDemo from "./CustomTimeZone.mjs"; -export * as CustomTimeZoneDemo from "./CustomTimeZone.mjs"; +import * as TimeZoneInfoDemo from "./TimeZoneInfo.mjs"; +export * as TimeZoneInfoDemo from "./TimeZoneInfo.mjs"; import * as TimeZoneIdMapperDemo from "./TimeZoneIdMapper.mjs"; export * as TimeZoneIdMapperDemo from "./TimeZoneIdMapper.mjs"; import * as TimeZoneIdMapperWithFastCanonicalizationDemo from "./TimeZoneIdMapperWithFastCanonicalization.mjs"; @@ -1122,45 +1122,21 @@ let termini = Object.assign({ ] }, - "CustomTimeZone.timeZoneId": { - func: CustomTimeZoneDemo.timeZoneId, + "TimeZoneInfo.timeZoneId": { + func: TimeZoneInfoDemo.timeZoneId, // For avoiding webpacking minifying issues: - funcName: "CustomTimeZone.timeZoneId", + funcName: "TimeZoneInfo.timeZoneId", parameters: [ - { - name: "S", - type: "string" - } - - ] - }, - - "CustomTimeZone.metazoneId": { - func: CustomTimeZoneDemo.metazoneId, - // For avoiding webpacking minifying issues: - funcName: "CustomTimeZone.metazoneId", - parameters: [ - - { - name: "S", - type: "string" - } - ] }, - "CustomTimeZone.zoneVariant": { - func: CustomTimeZoneDemo.zoneVariant, + "TimeZoneInfo.zoneVariant": { + func: TimeZoneInfoDemo.zoneVariant, // For avoiding webpacking minifying issues: - funcName: "CustomTimeZone.zoneVariant", + funcName: "TimeZoneInfo.zoneVariant", parameters: [ - { - name: "S", - type: "string" - } - ] }, @@ -1297,11 +1273,6 @@ let termini = Object.assign({ { name: "Nanosecond", type: "number" - }, - - { - name: "S", - type: "string" } ] @@ -1361,11 +1332,6 @@ let termini = Object.assign({ { name: "Name", type: "string" - }, - - { - name: "S", - type: "string" } ] @@ -1420,11 +1386,6 @@ let termini = Object.assign({ { name: "Nanosecond", type: "number" - }, - - { - name: "S", - type: "string" } ] diff --git a/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.d.ts b/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.d.ts index 4367c5755fb..aef979778be 100644 --- a/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.d.ts +++ b/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.d.ts @@ -1,10 +1,10 @@ // generated by diplomat-tool -import type { CustomTimeZone } from "./CustomTimeZone" import type { DataProvider } from "./DataProvider" import type { DateTimeLength } from "./DateTimeLength" import type { Error } from "./Error" import type { IsoDateTime } from "./IsoDateTime" import type { Locale } from "./Locale" +import type { TimeZoneInfo } from "./TimeZoneInfo" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; @@ -19,5 +19,5 @@ export class GregorianZonedDateTimeFormatter { static createWithLength(provider: DataProvider, locale: Locale, length: DateTimeLength): GregorianZonedDateTimeFormatter; - formatIsoDatetimeWithCustomTimeZone(datetime: IsoDateTime, timeZone: CustomTimeZone): string; + formatIsoDatetimeWithCustomTimeZone(datetime: IsoDateTime, timeZone: TimeZoneInfo): string; } \ No newline at end of file diff --git a/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.mjs b/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.mjs index b5d339975f4..a8f6f7c3911 100644 --- a/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.mjs +++ b/ffi/capi/bindings/js/GregorianZonedDateTimeFormatter.mjs @@ -1,10 +1,10 @@ // generated by diplomat-tool -import { CustomTimeZone } from "./CustomTimeZone.mjs" import { DataProvider } from "./DataProvider.mjs" import { DateTimeLength } from "./DateTimeLength.mjs" import { Error } from "./Error.mjs" import { IsoDateTime } from "./IsoDateTime.mjs" import { Locale } from "./Locale.mjs" +import { TimeZoneInfo } from "./TimeZoneInfo.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; diff --git a/ffi/capi/bindings/js/MetazoneCalculator.d.ts b/ffi/capi/bindings/js/MetazoneCalculator.d.ts deleted file mode 100644 index 8a5e5b7a2f2..00000000000 --- a/ffi/capi/bindings/js/MetazoneCalculator.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -// generated by diplomat-tool -import type { DataError } from "./DataError" -import type { DataProvider } from "./DataProvider" -import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -/** An object capable of computing the metazone from a timezone. -* -*This can be used via `maybe_calculate_metazone()` on [`CustomTimeZone`]. -* -*[`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -* -*See the [Rust documentation for `MetazoneCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html) for more information. -*/ -export class MetazoneCalculator { - - - get ffiValue(): pointer; - - static create(provider: DataProvider): MetazoneCalculator; -} \ No newline at end of file diff --git a/ffi/capi/bindings/js/MetazoneCalculator.mjs b/ffi/capi/bindings/js/MetazoneCalculator.mjs deleted file mode 100644 index c1df099410d..00000000000 --- a/ffi/capi/bindings/js/MetazoneCalculator.mjs +++ /dev/null @@ -1,64 +0,0 @@ -// generated by diplomat-tool -import { DataError } from "./DataError.mjs" -import { DataProvider } from "./DataProvider.mjs" -import wasm from "./diplomat-wasm.mjs"; -import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -/** An object capable of computing the metazone from a timezone. -* -*This can be used via `maybe_calculate_metazone()` on [`CustomTimeZone`]. -* -*[`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -* -*See the [Rust documentation for `MetazoneCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html) for more information. -*/ -const MetazoneCalculator_box_destroy_registry = new FinalizationRegistry((ptr) => { - wasm.icu4x_MetazoneCalculator_destroy_mv1(ptr); -}); - -export class MetazoneCalculator { - // Internal ptr reference: - #ptr = null; - - // Lifetimes are only to keep dependencies alive. - // Since JS won't garbage collect until there are no incoming edges. - #selfEdge = []; - - constructor(symbol, ptr, selfEdge) { - if (symbol !== diplomatRuntime.internalConstructor) { - console.error("MetazoneCalculator is an Opaque type. You cannot call its constructor."); - return; - } - - this.#ptr = ptr; - this.#selfEdge = selfEdge; - - // Are we being borrowed? If not, we can register. - if (this.#selfEdge.length === 0) { - MetazoneCalculator_box_destroy_registry.register(this, this.#ptr); - } - } - - get ffiValue() { - return this.#ptr; - } - - static create(provider) { - const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - - const result = wasm.icu4x_MetazoneCalculator_create_mv1(diplomatReceive.buffer, provider.ffiValue); - - try { - if (!diplomatReceive.resultFlag) { - const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); - throw new globalThis.Error('DataError: ' + cause.value, { cause }); - } - return new MetazoneCalculator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); - } - - finally { - diplomatReceive.free(); - } - } -} \ No newline at end of file diff --git a/ffi/capi/bindings/js/CustomTimeZone.d.ts b/ffi/capi/bindings/js/TimeZoneInfo.d.ts similarity index 62% rename from ffi/capi/bindings/js/CustomTimeZone.d.ts rename to ffi/capi/bindings/js/TimeZoneInfo.d.ts index 6b670400e34..597f4808fdc 100644 --- a/ffi/capi/bindings/js/CustomTimeZone.d.ts +++ b/ffi/capi/bindings/js/TimeZoneInfo.d.ts @@ -1,29 +1,27 @@ // generated by diplomat-tool import type { IsoDateTime } from "./IsoDateTime" -import type { MetazoneCalculator } from "./MetazoneCalculator" import type { TimeZoneIdMapper } from "./TimeZoneIdMapper" import type { TimeZoneInvalidOffsetError } from "./TimeZoneInvalidOffsetError" -import type { ZoneOffsetCalculator } from "./ZoneOffsetCalculator" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; -/** See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. +/** See the [Rust documentation for `TimeZoneInfo`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html) for more information. */ -export class CustomTimeZone { +export class TimeZoneInfo { get ffiValue(): pointer; - static fromString(s: string): CustomTimeZone; + static unknown(): TimeZoneInfo; - static unknown(): CustomTimeZone; - - static utc(): CustomTimeZone; + static utc(): TimeZoneInfo; trySetOffsetSeconds(offsetSeconds: number): void; setOffsetEighthsOfHour(offsetEighthsOfHour: number): void; + trySetOffsetStr(offset: string): void; + offsetEighthsOfHour(): number | null; clearOffset(): void; @@ -46,10 +44,6 @@ export class CustomTimeZone { get timeZoneId(): string; - setMetazoneId(id: string): void; - - get metazoneId(): string | null; - trySetZoneVariant(id: string): boolean; clearZoneVariant(): void; @@ -64,7 +58,9 @@ export class CustomTimeZone { get isDaylightTime(): boolean | null; - maybeCalculateMetazone(metazoneCalculator: MetazoneCalculator, localDatetime: IsoDateTime): void; + setLocalTime(datetime: IsoDateTime): void; + + clearLocalTime(): void; - maybeCalculateZoneVariant(zoneOffsetCalculator: ZoneOffsetCalculator, localDatetime: IsoDateTime): void; + getLocalTime(): IsoDateTime | null; } \ No newline at end of file diff --git a/ffi/capi/bindings/js/CustomTimeZone.mjs b/ffi/capi/bindings/js/TimeZoneInfo.mjs similarity index 64% rename from ffi/capi/bindings/js/CustomTimeZone.mjs rename to ffi/capi/bindings/js/TimeZoneInfo.mjs index f9457e07961..2d49d48624d 100644 --- a/ffi/capi/bindings/js/CustomTimeZone.mjs +++ b/ffi/capi/bindings/js/TimeZoneInfo.mjs @@ -1,20 +1,18 @@ // generated by diplomat-tool import { IsoDateTime } from "./IsoDateTime.mjs" -import { MetazoneCalculator } from "./MetazoneCalculator.mjs" import { TimeZoneIdMapper } from "./TimeZoneIdMapper.mjs" import { TimeZoneInvalidOffsetError } from "./TimeZoneInvalidOffsetError.mjs" -import { ZoneOffsetCalculator } from "./ZoneOffsetCalculator.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; -/** See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. +/** See the [Rust documentation for `TimeZoneInfo`](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneInfo.html) for more information. */ -const CustomTimeZone_box_destroy_registry = new FinalizationRegistry((ptr) => { - wasm.icu4x_CustomTimeZone_destroy_mv1(ptr); +const TimeZoneInfo_box_destroy_registry = new FinalizationRegistry((ptr) => { + wasm.icu4x_TimeZoneInfo_destroy_mv1(ptr); }); -export class CustomTimeZone { +export class TimeZoneInfo { // Internal ptr reference: #ptr = null; @@ -24,7 +22,7 @@ export class CustomTimeZone { constructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { - console.error("CustomTimeZone is an Opaque type. You cannot call its constructor."); + console.error("TimeZoneInfo is an Opaque type. You cannot call its constructor."); return; } @@ -33,7 +31,7 @@ export class CustomTimeZone { // Are we being borrowed? If not, we can register. if (this.#selfEdge.length === 0) { - CustomTimeZone_box_destroy_registry.register(this, this.#ptr); + TimeZoneInfo_box_destroy_registry.register(this, this.#ptr); } } @@ -41,44 +39,28 @@ export class CustomTimeZone { return this.#ptr; } - static fromString(s) { - let functionCleanupArena = new diplomatRuntime.CleanupArena(); - - const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, s)); - - const result = wasm.icu4x_CustomTimeZone_from_string_mv1(...sSlice.splat()); - - try { - return new CustomTimeZone(diplomatRuntime.internalConstructor, result, []); - } - - finally { - functionCleanupArena.free(); - } - } - static unknown() { - const result = wasm.icu4x_CustomTimeZone_unknown_mv1(); + const result = wasm.icu4x_TimeZoneInfo_unknown_mv1(); try { - return new CustomTimeZone(diplomatRuntime.internalConstructor, result, []); + return new TimeZoneInfo(diplomatRuntime.internalConstructor, result, []); } finally {} } static utc() { - const result = wasm.icu4x_CustomTimeZone_utc_mv1(); + const result = wasm.icu4x_TimeZoneInfo_utc_mv1(); try { - return new CustomTimeZone(diplomatRuntime.internalConstructor, result, []); + return new TimeZoneInfo(diplomatRuntime.internalConstructor, result, []); } finally {} } trySetOffsetSeconds(offsetSeconds) { - const result = wasm.icu4x_CustomTimeZone_try_set_offset_seconds_mv1(this.ffiValue, offsetSeconds); + const result = wasm.icu4x_TimeZoneInfo_try_set_offset_seconds_mv1(this.ffiValue, offsetSeconds); try { if (result !== 1) { @@ -91,17 +73,37 @@ export class CustomTimeZone { finally {} } - setOffsetEighthsOfHour(offsetEighthsOfHour) {wasm.icu4x_CustomTimeZone_set_offset_eighths_of_hour_mv1(this.ffiValue, offsetEighthsOfHour); + setOffsetEighthsOfHour(offsetEighthsOfHour) {wasm.icu4x_TimeZoneInfo_set_offset_eighths_of_hour_mv1(this.ffiValue, offsetEighthsOfHour); try {} finally {} } + trySetOffsetStr(offset) { + let functionCleanupArena = new diplomatRuntime.CleanupArena(); + + const offsetSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, offset)); + + const result = wasm.icu4x_TimeZoneInfo_try_set_offset_str_mv1(this.ffiValue, ...offsetSlice.splat()); + + try { + if (result !== 1) { + const cause = new TimeZoneInvalidOffsetError(diplomatRuntime.internalConstructor); + throw new globalThis.Error('TimeZoneInvalidOffsetError', { cause }); + } + + } + + finally { + functionCleanupArena.free(); + } + } + offsetEighthsOfHour() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); - const result = wasm.icu4x_CustomTimeZone_offset_eighths_of_hour_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_offset_eighths_of_hour_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -115,7 +117,7 @@ export class CustomTimeZone { } } - clearOffset() {wasm.icu4x_CustomTimeZone_clear_offset_mv1(this.ffiValue); + clearOffset() {wasm.icu4x_TimeZoneInfo_clear_offset_mv1(this.ffiValue); try {} @@ -125,7 +127,7 @@ export class CustomTimeZone { get offsetSeconds() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - const result = wasm.icu4x_CustomTimeZone_offset_seconds_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_offset_seconds_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -142,7 +144,7 @@ export class CustomTimeZone { get isOffsetPositive() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); - const result = wasm.icu4x_CustomTimeZone_is_offset_positive_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_is_offset_positive_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -159,7 +161,7 @@ export class CustomTimeZone { get isOffsetZero() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); - const result = wasm.icu4x_CustomTimeZone_is_offset_zero_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_is_offset_zero_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -176,7 +178,7 @@ export class CustomTimeZone { get offsetHoursPart() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - const result = wasm.icu4x_CustomTimeZone_offset_hours_part_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_offset_hours_part_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -193,7 +195,7 @@ export class CustomTimeZone { get offsetMinutesPart() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - const result = wasm.icu4x_CustomTimeZone_offset_minutes_part_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_offset_minutes_part_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -210,7 +212,7 @@ export class CustomTimeZone { get offsetSecondsPart() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - const result = wasm.icu4x_CustomTimeZone_offset_seconds_part_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_offset_seconds_part_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -228,7 +230,7 @@ export class CustomTimeZone { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, id)); - wasm.icu4x_CustomTimeZone_set_time_zone_id_mv1(this.ffiValue, ...idSlice.splat()); + wasm.icu4x_TimeZoneInfo_set_time_zone_id_mv1(this.ffiValue, ...idSlice.splat()); try {} @@ -241,7 +243,7 @@ export class CustomTimeZone { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, id)); - wasm.icu4x_CustomTimeZone_set_iana_time_zone_id_mv1(this.ffiValue, mapper.ffiValue, ...idSlice.splat()); + wasm.icu4x_TimeZoneInfo_set_iana_time_zone_id_mv1(this.ffiValue, mapper.ffiValue, ...idSlice.splat()); try {} @@ -252,7 +254,7 @@ export class CustomTimeZone { get timeZoneId() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); - wasm.icu4x_CustomTimeZone_time_zone_id_mv1(this.ffiValue, write.buffer); + wasm.icu4x_TimeZoneInfo_time_zone_id_mv1(this.ffiValue, write.buffer); try { return write.readString8(); @@ -263,39 +265,12 @@ export class CustomTimeZone { } } - setMetazoneId(id) { - let functionCleanupArena = new diplomatRuntime.CleanupArena(); - - const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, id)); - wasm.icu4x_CustomTimeZone_set_metazone_id_mv1(this.ffiValue, ...idSlice.splat()); - - try {} - - finally { - functionCleanupArena.free(); - } - } - - get metazoneId() { - const write = new diplomatRuntime.DiplomatWriteBuf(wasm); - - const result = wasm.icu4x_CustomTimeZone_metazone_id_mv1(this.ffiValue, write.buffer); - - try { - return result === 0 ? null : write.readString8(); - } - - finally { - write.free(); - } - } - trySetZoneVariant(id) { let functionCleanupArena = new diplomatRuntime.CleanupArena(); const idSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, id)); - const result = wasm.icu4x_CustomTimeZone_try_set_zone_variant_mv1(this.ffiValue, ...idSlice.splat()); + const result = wasm.icu4x_TimeZoneInfo_try_set_zone_variant_mv1(this.ffiValue, ...idSlice.splat()); try { return result === 1; @@ -306,7 +281,7 @@ export class CustomTimeZone { } } - clearZoneVariant() {wasm.icu4x_CustomTimeZone_clear_zone_variant_mv1(this.ffiValue); + clearZoneVariant() {wasm.icu4x_TimeZoneInfo_clear_zone_variant_mv1(this.ffiValue); try {} @@ -316,7 +291,7 @@ export class CustomTimeZone { get zoneVariant() { const write = new diplomatRuntime.DiplomatWriteBuf(wasm); - const result = wasm.icu4x_CustomTimeZone_zone_variant_mv1(this.ffiValue, write.buffer); + const result = wasm.icu4x_TimeZoneInfo_zone_variant_mv1(this.ffiValue, write.buffer); try { return result === 0 ? null : write.readString8(); @@ -327,14 +302,14 @@ export class CustomTimeZone { } } - setStandardTime() {wasm.icu4x_CustomTimeZone_set_standard_time_mv1(this.ffiValue); + setStandardTime() {wasm.icu4x_TimeZoneInfo_set_standard_time_mv1(this.ffiValue); try {} finally {} } - setDaylightTime() {wasm.icu4x_CustomTimeZone_set_daylight_time_mv1(this.ffiValue); + setDaylightTime() {wasm.icu4x_TimeZoneInfo_set_daylight_time_mv1(this.ffiValue); try {} @@ -344,7 +319,7 @@ export class CustomTimeZone { get isStandardTime() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); - const result = wasm.icu4x_CustomTimeZone_is_standard_time_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_is_standard_time_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -361,7 +336,7 @@ export class CustomTimeZone { get isDaylightTime() { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 2, 1, true); - const result = wasm.icu4x_CustomTimeZone_is_daylight_time_mv1(diplomatReceive.buffer, this.ffiValue); + const result = wasm.icu4x_TimeZoneInfo_is_daylight_time_mv1(diplomatReceive.buffer, this.ffiValue); try { if (!diplomatReceive.resultFlag) { @@ -375,17 +350,27 @@ export class CustomTimeZone { } } - maybeCalculateMetazone(metazoneCalculator, localDatetime) {wasm.icu4x_CustomTimeZone_maybe_calculate_metazone_mv1(this.ffiValue, metazoneCalculator.ffiValue, localDatetime.ffiValue); + setLocalTime(datetime) {wasm.icu4x_TimeZoneInfo_set_local_time_mv1(this.ffiValue, datetime.ffiValue); try {} finally {} } - maybeCalculateZoneVariant(zoneOffsetCalculator, localDatetime) {wasm.icu4x_CustomTimeZone_maybe_calculate_zone_variant_mv1(this.ffiValue, zoneOffsetCalculator.ffiValue, localDatetime.ffiValue); + clearLocalTime() {wasm.icu4x_TimeZoneInfo_clear_local_time_mv1(this.ffiValue); try {} finally {} } + + getLocalTime() { + const result = wasm.icu4x_TimeZoneInfo_get_local_time_mv1(this.ffiValue); + + try { + return result === 0 ? null : new IsoDateTime(diplomatRuntime.internalConstructor, result, []); + } + + finally {} + } } \ No newline at end of file diff --git a/ffi/capi/bindings/js/ZoneOffsetCalculator.d.ts b/ffi/capi/bindings/js/ZoneOffsetCalculator.d.ts deleted file mode 100644 index c47dfb95f92..00000000000 --- a/ffi/capi/bindings/js/ZoneOffsetCalculator.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -// generated by diplomat-tool -import type { DataError } from "./DataError" -import type { DataProvider } from "./DataProvider" -import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; - - -/** An object capable of computing UTC offsets from a timezone. -* -*This can be used via `maybe_calculate_zone_variant()` on [`CustomTimeZone`]. -* -*[`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -* -*See the [Rust documentation for `ZoneOffsetCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneOffsetCalculator.html) for more information. -*/ -export class ZoneOffsetCalculator { - - - get ffiValue(): pointer; - - static create(provider: DataProvider): ZoneOffsetCalculator; -} \ No newline at end of file diff --git a/ffi/capi/bindings/js/ZoneOffsetCalculator.mjs b/ffi/capi/bindings/js/ZoneOffsetCalculator.mjs deleted file mode 100644 index cecb45ac94c..00000000000 --- a/ffi/capi/bindings/js/ZoneOffsetCalculator.mjs +++ /dev/null @@ -1,64 +0,0 @@ -// generated by diplomat-tool -import { DataError } from "./DataError.mjs" -import { DataProvider } from "./DataProvider.mjs" -import wasm from "./diplomat-wasm.mjs"; -import * as diplomatRuntime from "./diplomat-runtime.mjs"; - - -/** An object capable of computing UTC offsets from a timezone. -* -*This can be used via `maybe_calculate_zone_variant()` on [`CustomTimeZone`]. -* -*[`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone -* -*See the [Rust documentation for `ZoneOffsetCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneOffsetCalculator.html) for more information. -*/ -const ZoneOffsetCalculator_box_destroy_registry = new FinalizationRegistry((ptr) => { - wasm.icu4x_ZoneOffsetCalculator_destroy_mv1(ptr); -}); - -export class ZoneOffsetCalculator { - // Internal ptr reference: - #ptr = null; - - // Lifetimes are only to keep dependencies alive. - // Since JS won't garbage collect until there are no incoming edges. - #selfEdge = []; - - constructor(symbol, ptr, selfEdge) { - if (symbol !== diplomatRuntime.internalConstructor) { - console.error("ZoneOffsetCalculator is an Opaque type. You cannot call its constructor."); - return; - } - - this.#ptr = ptr; - this.#selfEdge = selfEdge; - - // Are we being borrowed? If not, we can register. - if (this.#selfEdge.length === 0) { - ZoneOffsetCalculator_box_destroy_registry.register(this, this.#ptr); - } - } - - get ffiValue() { - return this.#ptr; - } - - static create(provider) { - const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); - - const result = wasm.icu4x_ZoneOffsetCalculator_create_mv1(diplomatReceive.buffer, provider.ffiValue); - - try { - if (!diplomatReceive.resultFlag) { - const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); - throw new globalThis.Error('DataError: ' + cause.value, { cause }); - } - return new ZoneOffsetCalculator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); - } - - finally { - diplomatReceive.free(); - } - } -} \ No newline at end of file diff --git a/ffi/capi/bindings/js/ZonedDateTimeFormatter.d.ts b/ffi/capi/bindings/js/ZonedDateTimeFormatter.d.ts index 75870eddea5..e78c2de4265 100644 --- a/ffi/capi/bindings/js/ZonedDateTimeFormatter.d.ts +++ b/ffi/capi/bindings/js/ZonedDateTimeFormatter.d.ts @@ -1,11 +1,11 @@ // generated by diplomat-tool -import type { CustomTimeZone } from "./CustomTimeZone" import type { DataProvider } from "./DataProvider" import type { DateTime } from "./DateTime" import type { DateTimeLength } from "./DateTimeLength" import type { Error } from "./Error" import type { IsoDateTime } from "./IsoDateTime" import type { Locale } from "./Locale" +import type { TimeZoneInfo } from "./TimeZoneInfo" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; @@ -20,7 +20,7 @@ export class ZonedDateTimeFormatter { static createWithLength(provider: DataProvider, locale: Locale, length: DateTimeLength): ZonedDateTimeFormatter; - formatDatetimeWithCustomTimeZone(datetime: DateTime, timeZone: CustomTimeZone): string; + formatDatetimeWithCustomTimeZone(datetime: DateTime, timeZone: TimeZoneInfo): string; - formatIsoDatetimeWithCustomTimeZone(datetime: IsoDateTime, timeZone: CustomTimeZone): string; + formatIsoDatetimeWithCustomTimeZone(datetime: IsoDateTime, timeZone: TimeZoneInfo): string; } \ No newline at end of file diff --git a/ffi/capi/bindings/js/ZonedDateTimeFormatter.mjs b/ffi/capi/bindings/js/ZonedDateTimeFormatter.mjs index 245db067eed..c142bb11b83 100644 --- a/ffi/capi/bindings/js/ZonedDateTimeFormatter.mjs +++ b/ffi/capi/bindings/js/ZonedDateTimeFormatter.mjs @@ -1,11 +1,11 @@ // generated by diplomat-tool -import { CustomTimeZone } from "./CustomTimeZone.mjs" import { DataProvider } from "./DataProvider.mjs" import { DateTime } from "./DateTime.mjs" import { DateTimeLength } from "./DateTimeLength.mjs" import { Error } from "./Error.mjs" import { IsoDateTime } from "./IsoDateTime.mjs" import { Locale } from "./Locale.mjs" +import { TimeZoneInfo } from "./TimeZoneInfo.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; diff --git a/ffi/capi/bindings/js/index.d.ts b/ffi/capi/bindings/js/index.d.ts index a33a8d50ea4..84598eeeda0 100644 --- a/ffi/capi/bindings/js/index.d.ts +++ b/ffi/capi/bindings/js/index.d.ts @@ -94,8 +94,6 @@ export { LocaleDirectionality } from "./LocaleDirectionality" export { Logger } from "./Logger" -export { MetazoneCalculator } from "./MetazoneCalculator" - export { ComposingNormalizer } from "./ComposingNormalizer" export { DecomposingNormalizer } from "./DecomposingNormalizer" @@ -166,7 +164,7 @@ export { WordSegmenter } from "./WordSegmenter" export { Time } from "./Time" -export { CustomTimeZone } from "./CustomTimeZone" +export { TimeZoneInfo } from "./TimeZoneInfo" export { TimeZoneIdMapper } from "./TimeZoneIdMapper" @@ -182,8 +180,6 @@ export { UnitsConverterFactory } from "./UnitsConverterFactory" export { WeekCalculator } from "./WeekCalculator" -export { ZoneOffsetCalculator } from "./ZoneOffsetCalculator" - export { GregorianZonedDateTimeFormatter } from "./GregorianZonedDateTimeFormatter" export { ZonedDateTimeFormatter } from "./ZonedDateTimeFormatter" diff --git a/ffi/capi/bindings/js/index.mjs b/ffi/capi/bindings/js/index.mjs index dd98151c23a..6badd4bfbbf 100644 --- a/ffi/capi/bindings/js/index.mjs +++ b/ffi/capi/bindings/js/index.mjs @@ -92,8 +92,6 @@ export { LocaleDirectionality } from "./LocaleDirectionality.mjs" export { Logger } from "./Logger.mjs" -export { MetazoneCalculator } from "./MetazoneCalculator.mjs" - export { ComposingNormalizer } from "./ComposingNormalizer.mjs" export { DecomposingNormalizer } from "./DecomposingNormalizer.mjs" @@ -164,7 +162,7 @@ export { WordSegmenter } from "./WordSegmenter.mjs" export { Time } from "./Time.mjs" -export { CustomTimeZone } from "./CustomTimeZone.mjs" +export { TimeZoneInfo } from "./TimeZoneInfo.mjs" export { TimeZoneIdMapper } from "./TimeZoneIdMapper.mjs" @@ -180,8 +178,6 @@ export { UnitsConverterFactory } from "./UnitsConverterFactory.mjs" export { WeekCalculator } from "./WeekCalculator.mjs" -export { ZoneOffsetCalculator } from "./ZoneOffsetCalculator.mjs" - export { GregorianZonedDateTimeFormatter } from "./GregorianZonedDateTimeFormatter.mjs" export { ZonedDateTimeFormatter } from "./ZonedDateTimeFormatter.mjs" diff --git a/ffi/capi/src/lib.rs b/ffi/capi/src/lib.rs index f312bf634fb..00fcc69214c 100644 --- a/ffi/capi/src/lib.rs +++ b/ffi/capi/src/lib.rs @@ -98,8 +98,6 @@ pub mod list; pub mod locale; #[cfg(feature = "locale")] pub mod locale_directionality; -#[cfg(feature = "timezone")] -pub mod metazone_calculator; #[cfg(feature = "normalizer")] pub mod normalizer; #[cfg(feature = "normalizer")] @@ -136,7 +134,5 @@ pub mod timezone_mapper; pub mod units_converter; #[cfg(feature = "calendar")] pub mod week; -#[cfg(feature = "timezone")] -pub mod zone_offset_calculator; #[cfg(feature = "datetime")] pub mod zoned_formatter; diff --git a/ffi/capi/src/metazone_calculator.rs b/ffi/capi/src/metazone_calculator.rs deleted file mode 100644 index 44467487b15..00000000000 --- a/ffi/capi/src/metazone_calculator.rs +++ /dev/null @@ -1,35 +0,0 @@ -// This file is part of ICU4X. For terms of use, please see the file -// called LICENSE at the top level of the ICU4X source tree -// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - -#[diplomat::bridge] -#[diplomat::abi_rename = "icu4x_{0}_mv1"] -#[diplomat::attr(auto, namespace = "icu4x")] -pub mod ffi { - use alloc::boxed::Box; - - use crate::errors::ffi::DataError; - use crate::provider::ffi::DataProvider; - - /// An object capable of computing the metazone from a timezone. - /// - /// This can be used via `maybe_calculate_metazone()` on [`CustomTimeZone`]. - /// - /// [`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone - #[diplomat::opaque] - #[diplomat::rust_link(icu::timezone::MetazoneCalculator, Struct)] - pub struct MetazoneCalculator(pub icu_timezone::MetazoneCalculator); - - impl MetazoneCalculator { - #[diplomat::rust_link(icu::timezone::MetazoneCalculator::new, FnInStruct)] - #[diplomat::attr(supports = fallible_constructors, constructor)] - pub fn create(provider: &DataProvider) -> Result, DataError> { - Ok(Box::new(MetazoneCalculator(call_constructor!( - icu_timezone::MetazoneCalculator::new [r => Ok(r)], - icu_timezone::MetazoneCalculator::try_new_with_any_provider, - icu_timezone::MetazoneCalculator::try_new_with_buffer_provider, - provider, - )?))) - } - } -} diff --git a/ffi/capi/src/timezone.rs b/ffi/capi/src/timezone.rs index 59a7752cc34..c74763c7b0a 100644 --- a/ffi/capi/src/timezone.rs +++ b/ffi/capi/src/timezone.rs @@ -10,43 +10,27 @@ pub mod ffi { use core::fmt::Write; use icu_timezone::TimeZoneBcp47Id; - use crate::errors::ffi::TimeZoneInvalidOffsetError; + use crate::{datetime::ffi::IsoDateTime, errors::ffi::TimeZoneInvalidOffsetError}; #[diplomat::opaque] - #[diplomat::rust_link(icu::timezone::CustomTimeZone, Struct)] - pub struct CustomTimeZone(pub icu_timezone::CustomTimeZone); - - impl CustomTimeZone { - /// Creates a time zone from an offset string. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::from_str, FnInStruct)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::from_utf8, FnInStruct, hidden)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::from_parts, FnInStruct, hidden)] - #[diplomat::rust_link(icu::timezone::UtcOffset::try_from_str, FnInStruct, hidden)] - #[diplomat::rust_link(icu::timezone::UtcOffset::try_from_utf8, FnInStruct, hidden)] - #[diplomat::rust_link(icu::timezone::UtcOffset::from_str, FnInStruct, hidden)] - #[diplomat::attr(supports = fallible_constructors, named_constructor)] - #[diplomat::demo(default_constructor)] - #[cfg(feature = "compiled_data")] - pub fn from_string(s: &DiplomatStr) -> Box { - Box::new(CustomTimeZone::from( - icu_timezone::CustomTimeZone::from_utf8(s), - )) - } + #[diplomat::rust_link(icu::timezone::TimeZoneInfo, Struct)] + pub struct TimeZoneInfo(pub icu_timezone::TimeZoneInfo); + impl TimeZoneInfo { /// Creates a time zone with no information. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::unknown, FnInStruct)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::unknown, FnInStruct)] #[diplomat::rust_link(icu::timezone::TimeZoneBcp47Id::unknown, FnInStruct, hidden)] - #[diplomat::attr(supports = fallible_constructors, named_constructor)] - pub fn unknown() -> Box { - Box::new(icu_timezone::CustomTimeZone::unknown().into()) + #[diplomat::attr(supports = fallible_constructors, constructor)] + pub fn unknown() -> Box { + Box::new(icu_timezone::TimeZoneInfo::unknown().into()) } /// Creates a time zone for UTC (Coordinated Universal Time). - #[diplomat::rust_link(icu::timezone::CustomTimeZone::utc, FnInStruct)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::utc, FnInStruct)] #[diplomat::rust_link(icu::timezone::UtcOffset::zero, FnInStruct, hidden)] #[diplomat::attr(supports = fallible_constructors, named_constructor)] - pub fn utc() -> Box { - Box::new(icu_timezone::CustomTimeZone::utc().into()) + pub fn utc() -> Box { + Box::new(icu_timezone::TimeZoneInfo::utc().into()) } /// Sets the `offset` field from offset seconds. @@ -55,7 +39,7 @@ pub mod ffi { #[diplomat::rust_link(icu::timezone::UtcOffset::try_from_seconds, FnInStruct)] #[diplomat::rust_link(icu::timezone::UtcOffset, Struct, compact)] #[diplomat::rust_link(icu::timezone::UtcOffset::from_seconds_unchecked, FnInStruct, hidden)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::new_with_offset, FnInStruct, hidden)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::new_with_offset, FnInStruct, hidden)] pub fn try_set_offset_seconds( &mut self, offset_seconds: i32, @@ -72,6 +56,21 @@ pub mod ffi { )); } + /// Sets the `offset` field from a string. + #[diplomat::rust_link(icu::timezone::UtcOffset::try_from_str, FnInStruct)] + #[diplomat::rust_link(icu::timezone::UtcOffset::try_from_utf8, FnInStruct, hidden)] + #[diplomat::rust_link(icu::timezone::UtcOffset::from_str, FnInStruct, hidden)] + pub fn try_set_offset_str( + &mut self, + offset: &DiplomatStr, + ) -> Result<(), TimeZoneInvalidOffsetError> { + self.0.offset = Some( + icu_timezone::UtcOffset::try_from_utf8(offset) + .map_err(|_| TimeZoneInvalidOffsetError)?, + ); + Ok(()) + } + /// Gets the `offset` field from offset as eighths of an hour. #[diplomat::rust_link(icu::timezone::UtcOffset::to_eighths_of_hour, FnInStruct)] pub fn offset_eighths_of_hour(&self) -> Option { @@ -145,7 +144,7 @@ pub mod ffi { /// Sets the `time_zone_id` field from a BCP-47 string. /// /// Errors if the string is not a valid BCP-47 time zone ID. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::time_zone_id, StructField)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::time_zone_id, StructField)] #[diplomat::rust_link(icu::timezone::TimeZoneBcp47Id, Struct, compact)] #[diplomat::rust_link(icu::timezone::TimeZoneBcp47Id::from_str, FnInStruct, hidden)] #[diplomat::rust_link(icu::timezone::TimeZoneBcp47Id::deref, FnInStruct, hidden)] @@ -173,42 +172,17 @@ pub mod ffi { /// Writes the value of the `time_zone_id` field as a string. /// /// Returns null if the `time_zone_id` field is empty. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::time_zone_id, StructField)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::time_zone_id, StructField)] #[diplomat::rust_link(icu::timezone::TimeZoneBcp47Id, Struct, compact)] #[diplomat::attr(auto, getter)] pub fn time_zone_id(&self, write: &mut diplomat_runtime::DiplomatWrite) { let _infallible = write.write_str(self.0.time_zone_id.0.as_str()); } - /// Sets the `metazone_id` field from a string. - /// - /// Returns null if the string is not a valid BCP-47 metazone ID. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::metazone_id, StructField)] - #[diplomat::rust_link(icu::timezone::MetazoneId, Struct, compact)] - #[diplomat::rust_link(icu::timezone::MetazoneId::from_str, FnInStruct, hidden)] - pub fn set_metazone_id(&mut self, id: &DiplomatStr) { - self.0.metazone_id = Some( - tinystr::TinyAsciiStr::try_from_utf8(id) - .ok() - .map(icu_timezone::MetazoneId), - ); - } - - /// Writes the value of the `metazone_id` field as a string. - /// - /// Returns null if the `metazone_id` field is empty or unresolved. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::metazone_id, StructField)] - #[diplomat::rust_link(icu::timezone::MetazoneId, Struct, compact)] - #[diplomat::attr(auto, getter)] - pub fn metazone_id(&self, write: &mut diplomat_runtime::DiplomatWrite) -> Option<()> { - let _infallible = write.write_str(self.0.metazone_id??.0.as_str()); - Some(()) - } - /// Sets the `zone_variant` field from a string. /// /// Returns null if the string is not a valid zone variant. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField)] #[diplomat::rust_link(icu::timezone::ZoneVariant, Struct, compact)] #[diplomat::rust_link(icu::timezone::ZoneVariant::from_str, FnInStruct, hidden)] pub fn try_set_zone_variant(&mut self, id: &DiplomatStr) -> Option<()> { @@ -219,7 +193,7 @@ pub mod ffi { } /// Clears the `zone_variant` field. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField)] #[diplomat::rust_link(icu::timezone::ZoneVariant, Struct, compact)] pub fn clear_zone_variant(&mut self) { self.0.zone_variant.take(); @@ -228,7 +202,7 @@ pub mod ffi { /// Writes the value of the `zone_variant` field as a string. /// /// Returns null if the `zone_variant` field is empty. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField)] #[diplomat::rust_link(icu::timezone::ZoneVariant, Struct, compact)] #[diplomat::attr(auto, getter)] pub fn zone_variant(&self, write: &mut diplomat_runtime::DiplomatWrite) -> Option<()> { @@ -239,7 +213,7 @@ pub mod ffi { /// Sets the `zone_variant` field to "standard" time, which may or may /// not correspond to a display name with "Standard" in its name. #[diplomat::rust_link(icu::timezone::ZoneVariant::standard, FnInStruct)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField, compact)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField, compact)] pub fn set_standard_time(&mut self) { self.0.zone_variant = Some(icu_timezone::ZoneVariant::standard()) } @@ -247,7 +221,7 @@ pub mod ffi { /// Sets the `zone_variant` field to "daylight" time, which may or may /// not correspond to a display name with "Daylight" in its name. #[diplomat::rust_link(icu::timezone::ZoneVariant::daylight, FnInStruct)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField, compact)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField, compact)] pub fn set_daylight_time(&mut self) { self.0.zone_variant = Some(icu_timezone::ZoneVariant::daylight()) } @@ -256,7 +230,7 @@ pub mod ffi { /// /// Returns null if the `zone_variant` field is empty. #[diplomat::rust_link(icu::timezone::ZoneVariant::standard, FnInStruct)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField, compact)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField, compact)] #[diplomat::attr(auto, getter)] pub fn is_standard_time(&self) -> Option { Some(self.0.zone_variant? == icu_timezone::ZoneVariant::standard()) @@ -266,59 +240,42 @@ pub mod ffi { /// /// Returns null if the `zone_variant` field is empty. #[diplomat::rust_link(icu::timezone::ZoneVariant::daylight, FnInStruct)] - #[diplomat::rust_link(icu::timezone::CustomTimeZone::zone_variant, StructField, compact)] + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::zone_variant, StructField, compact)] #[diplomat::attr(auto, getter)] pub fn is_daylight_time(&self) -> Option { Some(self.0.zone_variant? == icu_timezone::ZoneVariant::daylight()) } - /// Sets the metazone based on the time zone and the local timestamp. - #[diplomat::rust_link(icu::timezone::CustomTimeZone::maybe_calculate_metazone, FnInStruct)] - #[diplomat::rust_link( - icu::timezone::MetazoneCalculator::compute_metazone_from_time_zone, - FnInStruct, - compact - )] - #[cfg(feature = "timezone")] - pub fn maybe_calculate_metazone( - &mut self, - metazone_calculator: &crate::metazone_calculator::ffi::MetazoneCalculator, - local_datetime: &crate::datetime::ffi::IsoDateTime, - ) { - self.0 - .maybe_calculate_metazone(&metazone_calculator.0, &local_datetime.0); + /// Sets the `local_time` field. + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::local_time, StructField)] + pub fn set_local_time(&mut self, datetime: &IsoDateTime) { + self.0.local_time = Some((datetime.0.date, datetime.0.time)); } - /// Sets the zone variant based on the time zone and the local timestamp. - #[diplomat::rust_link( - icu::timezone::CustomTimeZone::maybe_calculate_zone_variant, - FnInStruct - )] - #[diplomat::rust_link( - icu::timezone::ZoneOffsetCalculator::compute_offsets_from_time_zone, - FnInStruct, - compact - )] - #[cfg(feature = "timezone")] - pub fn maybe_calculate_zone_variant( - &mut self, - zone_offset_calculator: &crate::zone_offset_calculator::ffi::ZoneOffsetCalculator, - local_datetime: &crate::datetime::ffi::IsoDateTime, - ) { + /// Clears the `local_time` field. + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::local_time, StructField)] + pub fn clear_local_time(&mut self) { + self.0.local_time.take(); + } + + /// Returns a copy of the `local_time` field. + #[diplomat::rust_link(icu::timezone::TimeZoneInfo::local_time, StructField, compact)] + pub fn get_local_time(&self) -> Option> { self.0 - .maybe_calculate_zone_variant(&zone_offset_calculator.0, &local_datetime.0); + .local_time + .map(|(date, time)| Box::new(IsoDateTime(icu_calendar::DateTime { date, time }))) } } } -impl From for ffi::CustomTimeZone { - fn from(other: icu_timezone::CustomTimeZone) -> Self { +impl From for ffi::TimeZoneInfo { + fn from(other: icu_timezone::TimeZoneInfo) -> Self { Self(other) } } -impl From for icu_timezone::CustomTimeZone { - fn from(other: ffi::CustomTimeZone) -> Self { +impl From for icu_timezone::TimeZoneInfo { + fn from(other: ffi::TimeZoneInfo) -> Self { other.0 } } diff --git a/ffi/capi/src/zone_offset_calculator.rs b/ffi/capi/src/zone_offset_calculator.rs deleted file mode 100644 index 0243a7e3b20..00000000000 --- a/ffi/capi/src/zone_offset_calculator.rs +++ /dev/null @@ -1,35 +0,0 @@ -// This file is part of ICU4X. For terms of use, please see the file -// called LICENSE at the top level of the ICU4X source tree -// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). - -#[diplomat::bridge] -#[diplomat::abi_rename = "icu4x_{0}_mv1"] -#[diplomat::attr(auto, namespace = "icu4x")] -pub mod ffi { - use alloc::boxed::Box; - - use crate::errors::ffi::DataError; - use crate::provider::ffi::DataProvider; - - /// An object capable of computing UTC offsets from a timezone. - /// - /// This can be used via `maybe_calculate_zone_variant()` on [`CustomTimeZone`]. - /// - /// [`CustomTimeZone`]: crate::timezone::ffi::CustomTimeZone - #[diplomat::opaque] - #[diplomat::rust_link(icu::timezone::ZoneOffsetCalculator, Struct)] - pub struct ZoneOffsetCalculator(pub icu_timezone::ZoneOffsetCalculator); - - impl ZoneOffsetCalculator { - #[diplomat::rust_link(icu::timezone::ZoneOffsetCalculator::new, FnInStruct)] - #[diplomat::attr(supports = fallible_constructors, constructor)] - pub fn create(provider: &DataProvider) -> Result, DataError> { - Ok(Box::new(ZoneOffsetCalculator(call_constructor!( - icu_timezone::ZoneOffsetCalculator::new [r => Ok(r)], - icu_timezone::ZoneOffsetCalculator::try_new_with_any_provider, - icu_timezone::ZoneOffsetCalculator::try_new_with_buffer_provider, - provider, - )?))) - } - } -} diff --git a/ffi/capi/src/zoned_formatter.rs b/ffi/capi/src/zoned_formatter.rs index 1b38dfe91e1..36d69f14e7d 100644 --- a/ffi/capi/src/zoned_formatter.rs +++ b/ffi/capi/src/zoned_formatter.rs @@ -15,7 +15,7 @@ pub mod ffi { use crate::{ datetime::ffi::DateTime, datetime::ffi::IsoDateTime, datetime_formatter::ffi::DateTimeLength, errors::ffi::Error, locale_core::ffi::Locale, - provider::ffi::DataProvider, timezone::ffi::CustomTimeZone, + provider::ffi::DataProvider, timezone::ffi::TimeZoneInfo, }; use writeable::TryWriteable; @@ -59,11 +59,11 @@ pub mod ffi { ))) } - /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. + /// Formats a [`IsoDateTime`] and [`TimeZoneInfo`] to a string. pub fn format_iso_datetime_with_custom_time_zone( &self, datetime: &IsoDateTime, - time_zone: &CustomTimeZone, + time_zone: &TimeZoneInfo, write: &mut diplomat_runtime::DiplomatWrite, ) { let greg = icu_calendar::DateTime::new_from_iso(datetime.0, icu_calendar::Gregorian); @@ -112,11 +112,11 @@ pub mod ffi { )?))) } - /// Formats a [`DateTime`] and [`CustomTimeZone`] to a string. + /// Formats a [`DateTime`] and [`TimeZoneInfo`] to a string. pub fn format_datetime_with_custom_time_zone( &self, datetime: &DateTime, - time_zone: &CustomTimeZone, + time_zone: &TimeZoneInfo, write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), Error> { let zdt = icu_timezone::CustomZonedDateTime { @@ -128,11 +128,11 @@ pub mod ffi { Ok(()) } - /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. + /// Formats a [`IsoDateTime`] and [`TimeZoneInfo`] to a string. pub fn format_iso_datetime_with_custom_time_zone( &self, datetime: &IsoDateTime, - time_zone: &CustomTimeZone, + time_zone: &TimeZoneInfo, write: &mut diplomat_runtime::DiplomatWrite, ) -> Result<(), Error> { let zdt = icu_timezone::CustomZonedDateTime { diff --git a/ffi/capi/tests/missing_apis.txt b/ffi/capi/tests/missing_apis.txt index 7d8542f2be2..5223fa580f2 100644 --- a/ffi/capi/tests/missing_apis.txt +++ b/ffi/capi/tests/missing_apis.txt @@ -209,7 +209,6 @@ icu::properties::props::GeneralCategoryGroup::union#FnInStruct icu::properties::props::GeneralCategoryOutOfBoundsError#Struct icu::segmenter::SentenceBreakOptions#Struct icu::segmenter::WordBreakOptions#Struct -icu::timezone::CustomTimeZone::new_with_bcp47_id#FnInStruct icu::timezone::CustomZonedDateTime#Struct icu::timezone::CustomZonedDateTime::from_str#FnInStruct icu::timezone::CustomZonedDateTime::to_calendar#FnInStruct @@ -226,3 +225,6 @@ icu::timezone::WindowsTimeZoneMapperBorrowed#Struct icu::timezone::WindowsTimeZoneMapperBorrowed::new#FnInStruct icu::timezone::WindowsTimeZoneMapperBorrowed::windows_tz_to_bcp47_id#FnInStruct icu::timezone::WindowsTimeZoneMapperBorrowed::windows_tz_to_bcp47_id_with_region#FnInStruct +icu::timezone::ZoneOffsetCalculator#Struct +icu::timezone::ZoneOffsetCalculator::compute_offsets_from_time_zone#FnInStruct +icu::timezone::ZoneOffsetCalculator::new#FnInStruct diff --git a/provider/data/timezone/data/metazone_period_v1_marker.rs.data b/provider/data/datetime/data/metazone_period_v1_marker.rs.data similarity index 94% rename from provider/data/timezone/data/metazone_period_v1_marker.rs.data rename to provider/data/datetime/data/metazone_period_v1_marker.rs.data index 61f472883ec..bb597013143 100644 --- a/provider/data/timezone/data/metazone_period_v1_marker.rs.data +++ b/provider/data/datetime/data/metazone_period_v1_marker.rs.data @@ -16,18 +16,18 @@ macro_rules! __impl_metazone_period_v1_marker { #[clippy::msrv = "1.71.1"] impl $provider { #[doc(hidden)] - pub const SINGLETON_METAZONE_PERIOD_V1_MARKER: &'static ::DataStruct = &icu::timezone::provider::MetazonePeriodV1(unsafe { + pub const SINGLETON_METAZONE_PERIOD_V1_MARKER: &'static ::DataStruct = &icu::datetime::provider::time_zones::MetazonePeriodV1(unsafe { #[allow(unused_unsafe)] zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"adalv\0\0\0aedxb\0\0\0afkbl\0\0\0aganu\0\0\0aiaxa\0\0\0altia\0\0\0amevn\0\0\0ancur\0\0\0aolad\0\0\0aqcas\0\0\0aqdav\0\0\0aqddu\0\0\0aqmaw\0\0\0aqmcm\0\0\0aqplm\0\0\0aqrot\0\0\0aqsyw\0\0\0aqtrl\0\0\0aqvos\0\0\0arbue\0\0\0arcor\0\0\0arctc\0\0\0arirj\0\0\0arjuj\0\0\0arluq\0\0\0armdz\0\0\0arrgl\0\0\0arsla\0\0\0artuc\0\0\0aruaq\0\0\0arush\0\0\0asppg\0\0\0atvie\0\0\0auadl\0\0\0aubhq\0\0\0aubne\0\0\0audrw\0\0\0aueuc\0\0\0auhba\0\0\0auldc\0\0\0auldh\0\0\0aumel\0\0\0aumqi\0\0\0auper\0\0\0ausyd\0\0\0awaua\0\0\0azbak\0\0\0basjj\0\0\0bbbgi\0\0\0bddac\0\0\0bebru\0\0\0bfoua\0\0\0bgsof\0\0\0bhbah\0\0\0bibjm\0\0\0bjptn\0\0\0bmbda\0\0\0bnbwn\0\0\0bolpb\0\0\0bqkra\0\0\0braux\0\0\0brbel\0\0\0brbvb\0\0\0brcgb\0\0\0brcgr\0\0\0brern\0\0\0brfen\0\0\0brfor\0\0\0brmao\0\0\0brmcz\0\0\0brpvh\0\0\0brrbr\0\0\0brrec\0\0\0brsao\0\0\0brssa\0\0\0brstm\0\0\0bsnas\0\0\0btthi\0\0\0bwgbe\0\0\0bymsq\0\0\0bzbze\0\0\0cacfq\0\0\0caedm\0\0\0cafne\0\0\0caglb\0\0\0cagoo\0\0\0cahal\0\0\0caiql\0\0\0camon\0\0\0careb\0\0\0careg\0\0\0casjf\0\0\0cator\0\0\0cavan\0\0\0cawnp\0\0\0caybx\0\0\0caycb\0\0\0cayda\0\0\0caydq\0\0\0cayek\0\0\0cayev\0\0\0cayxy\0\0\0cayyn\0\0\0cayzs\0\0\0cccck\0\0\0cdfbm\0\0\0cdfih\0\0\0cfbgf\0\0\0cgbzv\0\0\0chzrh\0\0\0ciabj\0\0\0ckrar\0\0\0clipc\0\0\0clpuq\0\0\0clscl\0\0\0cmdla\0\0\0cnsha\0\0\0cnurc\0\0\0cobog\0\0\0crsjo\0\0\0cuhav\0\0\0cvrai\0\0\0cxxch\0\0\0cyfmg\0\0\0cynic\0\0\0czprg\0\0\0deber\0\0\0debsngn\0djjib\0\0\0dkcph\0\0\0dmdom\0\0\0dosdq\0\0\0dzalg\0\0\0ecgps\0\0\0ecgye\0\0\0eetll\0\0\0egcai\0\0\0eheai\0\0\0erasm\0\0\0esceu\0\0\0eslpa\0\0\0esmad\0\0\0etadd\0\0\0fihel\0\0\0fimhq\0\0\0fjsuv\0\0\0fkpsy\0\0\0fmksa\0\0\0fmpni\0\0\0fmtkk\0\0\0fotho\0\0\0frpar\0\0\0galbv\0\0\0gazastrpgblon\0\0\0gdgnd\0\0\0getbs\0\0\0gfcay\0\0\0gggci\0\0\0ghacc\0\0\0gigib\0\0\0gldkshvnglgoh\0\0\0globy\0\0\0glthu\0\0\0gmbjl\0\0\0gmt\0\0\0\0\0gncky\0\0\0gpbbr\0\0\0gpmsb\0\0\0gpsbh\0\0\0gqssg\0\0\0grath\0\0\0gsgrv\0\0\0gtgua\0\0\0gugum\0\0\0gwoxb\0\0\0gygeo\0\0\0hebron\0\0hkhkg\0\0\0hntgu\0\0\0hrzag\0\0\0htpap\0\0\0hubud\0\0\0iddjj\0\0\0idjkt\0\0\0idmak\0\0\0idpnk\0\0\0iedub\0\0\0imdgs\0\0\0inccu\0\0\0iodga\0\0\0iqbgw\0\0\0irthr\0\0\0isrey\0\0\0itrom\0\0\0jeruslm\0jesth\0\0\0jmkin\0\0\0joamm\0\0\0jptyo\0\0\0kenbo\0\0\0kgfru\0\0\0khpnh\0\0\0kicxi\0\0\0kipho\0\0\0kitrw\0\0\0kmyva\0\0\0knbas\0\0\0kpfnj\0\0\0krsel\0\0\0kwkwi\0\0\0kygec\0\0\0kzaau\0\0\0kzakx\0\0\0kzala\0\0\0kzguw\0\0\0kzksn\0\0\0kzkzo\0\0\0kzura\0\0\0lavte\0\0\0lbbey\0\0\0lccas\0\0\0livdz\0\0\0lkcmb\0\0\0lrmlw\0\0\0lsmsu\0\0\0ltvno\0\0\0lulux\0\0\0lvrix\0\0\0lytip\0\0\0macas\0\0\0mcmon\0\0\0mdkiv\0\0\0metgd\0\0\0mgtnr\0\0\0mhkwa\0\0\0mhmaj\0\0\0mkskp\0\0\0mlbko\0\0\0mmrgn\0\0\0mnhvd\0\0\0mnuln\0\0\0momfm\0\0\0mpspn\0\0\0mqfdf\0\0\0mrnkc\0\0\0msmni\0\0\0mtmla\0\0\0muplu\0\0\0mvmle\0\0\0mwblz\0\0\0mxchi\0\0\0mxcjs\0\0\0mxcun\0\0\0mxhmo\0\0\0mxmam\0\0\0mxmex\0\0\0mxmid\0\0\0mxmty\0\0\0mxmzt\0\0\0mxoji\0\0\0mxpvr\0\0\0mxtij\0\0\0mykch\0\0\0mykul\0\0\0mzmpm\0\0\0nawdh\0\0\0ncnou\0\0\0nenim\0\0\0nfnlk\0\0\0nglos\0\0\0nimga\0\0\0nlams\0\0\0noosl\0\0\0npktm\0\0\0nrinu\0\0\0nuiue\0\0\0nzakl\0\0\0nzcht\0\0\0ommct\0\0\0papty\0\0\0pelim\0\0\0pfgmr\0\0\0pfnhv\0\0\0pfppt\0\0\0pgpom\0\0\0pgraw\0\0\0phmnl\0\0\0pkkhi\0\0\0plwaw\0\0\0pmmqc\0\0\0pnpcn\0\0\0prsju\0\0\0ptfnc\0\0\0ptlis\0\0\0ptpdl\0\0\0pwror\0\0\0pyasu\0\0\0qadoh\0\0\0rereu\0\0\0robuh\0\0\0rsbeg\0\0\0ruasf\0\0\0ruchita\0rudyr\0\0\0rugdx\0\0\0ruikt\0\0\0rukgd\0\0\0rukhndg\0rukra\0\0\0rukuf\0\0\0rumow\0\0\0runoz\0\0\0ruoms\0\0\0ruovb\0\0\0rupkc\0\0\0rurtw\0\0\0rusred\0\0ruuly\0\0\0ruunera\0ruuus\0\0\0ruvog\0\0\0ruvvo\0\0\0ruyek\0\0\0ruyks\0\0\0rwkgl\0\0\0saruh\0\0\0sbhir\0\0\0scmaw\0\0\0sdkrt\0\0\0sesto\0\0\0sgsin\0\0\0shshn\0\0\0silju\0\0\0sjlyr\0\0\0skbts\0\0\0slfna\0\0\0smsai\0\0\0sndkr\0\0\0somgq\0\0\0srpbm\0\0\0ssjub\0\0\0sttms\0\0\0svsal\0\0\0sxphi\0\0\0sydam\0\0\0szqmn\0\0\0tcgdt\0\0\0tdndj\0\0\0tfpfr\0\0\0tglfw\0\0\0thbkk\0\0\0tjdyu\0\0\0tkfko\0\0\0tldil\0\0\0tmasb\0\0\0tntun\0\0\0totbu\0\0\0trist\0\0\0ttpos\0\0\0tvfun\0\0\0twtpe\0\0\0tzdar\0\0\0uaiev\0\0\0uasip\0\0\0ugkla\0\0\0umawk\0\0\0ummdy\0\0\0usadk\0\0\0usaeg\0\0\0usanc\0\0\0usboi\0\0\0uschi\0\0\0usden\0\0\0usdet\0\0\0ushnl\0\0\0usind\0\0\0usinvev\0usjnu\0\0\0usknx\0\0\0uslax\0\0\0uslui\0\0\0usmnm\0\0\0usmoc\0\0\0usmtm\0\0\0usndcnt\0usndnsl\0usnyc\0\0\0usoea\0\0\0usome\0\0\0usphx\0\0\0ussit\0\0\0ustel\0\0\0uswlz\0\0\0uswsq\0\0\0usxul\0\0\0usyak\0\0\0uymvd\0\0\0uzskd\0\0\0uztas\0\0\0vavat\0\0\0vcsvd\0\0\0veccs\0\0\0vgtov\0\0\0vistt\0\0\0vnsgn\0\0\0vuvli\0\0\0wfmau\0\0\0wsapw\0\0\0yeade\0\0\0ytmam\0\0\0zajnb\0\0\0zmlun\0\0\0zwhre\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04\0\0\0\x05\0\0\0\x06\0\0\0\x08\0\0\0\t\0\0\0\n\0\0\0\x1B\0\0\0\x1C\0\0\0\x1D\0\0\0\x1E\0\0\0\x1F\0\0\0!\0\0\0\"\0\0\0#\0\0\0$\0\0\0%\0\0\0&\0\0\0(\0\0\0,\0\0\x001\0\0\x003\0\0\0<\0\0\0?\0\0\0B\0\0\0D\0\0\0H\0\0\0M\0\0\0O\0\0\0Q\0\0\0R\0\0\0S\0\0\0T\0\0\0U\0\0\0V\0\0\0W\0\0\0X\0\0\0Y\0\0\0[\0\0\0\\\0\0\0]\0\0\0^\0\0\0_\0\0\0`\0\0\0b\0\0\0c\0\0\0d\0\0\0f\0\0\0g\0\0\0h\0\0\0i\0\0\0k\0\0\0l\0\0\0m\0\0\0n\0\0\0o\0\0\0p\0\0\0q\0\0\0r\0\0\0s\0\0\0t\0\0\0u\0\0\0v\0\0\0y\0\0\0z\0\0\0{\0\0\0|\0\0\0}\0\0\0~\0\0\0\x81\0\0\0\x82\0\0\0\x83\0\0\0\x84\0\0\0\x86\0\0\0\x87\0\0\0\x89\0\0\0\x8A\0\0\0\x8E\0\0\0\x8F\0\0\0\x90\0\0\0\x91\0\0\0\x93\0\0\0\x94\0\0\0\x97\0\0\0\x98\0\0\0\x9B\0\0\0\x9C\0\0\0\xA1\0\0\0\xA2\0\0\0\xA3\0\0\0\xA4\0\0\0\xA5\0\0\0\xA6\0\0\0\xA7\0\0\0\xAC\0\0\0\xAE\0\0\0\xB0\0\0\0\xB3\0\0\0\xB5\0\0\0\xB7\0\0\0\xB9\0\0\0\xBA\0\0\0\xBB\0\0\0\xBC\0\0\0\xBD\0\0\0\xBE\0\0\0\xBF\0\0\0\xC0\0\0\0\xC1\0\0\0\xC2\0\0\0\xC3\0\0\0\xC4\0\0\0\xC5\0\0\0\xC6\0\0\0\xC7\0\0\0\xC8\0\0\0\xC9\0\0\0\xCA\0\0\0\xCB\0\0\0\xCC\0\0\0\xCD\0\0\0\xCE\0\0\0\xCF\0\0\0\xD0\0\0\0\xD1\0\0\0\xD2\0\0\0\xD3\0\0\0\xD4\0\0\0\xD5\0\0\0\xD9\0\0\0\xDD\0\0\0\xDF\0\0\0\xE0\0\0\0\xE2\0\0\0\xE3\0\0\0\xE5\0\0\0\xE6\0\0\0\xE8\0\0\0\xE9\0\0\0\xEA\0\0\0\xEB\0\0\0\xEC\0\0\0\xED\0\0\0\xEE\0\0\0\xEF\0\0\0\xF0\0\0\0\xF1\0\0\0\xF2\0\0\0\xF3\0\0\0\xF4\0\0\0\xF5\0\0\0\xF7\0\0\0\xF9\0\0\0\xFA\0\0\0\xFC\0\0\0\xFD\0\0\0\xFF\0\0\0\0\x01\0\0\x01\x01\0\0\x03\x01\0\0\x05\x01\0\0\x08\x01\0\0\t\x01\0\0\n\x01\0\0\x0B\x01\0\0\x0C\x01\0\0\r\x01\0\0\x0E\x01\0\0\x0F\x01\0\0\x10\x01\0\0\x11\x01\0\0\x12\x01\0\0\x13\x01\0\0\x15\x01\0\0\x17\x01\0\0\x18\x01\0\0\x1A\x01\0\0\x1B\x01\0\0\x1C\x01\0\0\x1D\x01\0\0\x1E\x01\0\0\x1F\x01\0\0 \x01\0\0!\x01\0\0\"\x01\0\0$\x01\0\0&\x01\0\0(\x01\0\0)\x01\0\0*\x01\0\0+\x01\0\0,\x01\0\0-\x01\0\0.\x01\0\0/\x01\0\x001\x01\0\x002\x01\0\x003\x01\0\x004\x01\0\x005\x01\0\x007\x01\0\08\x01\0\09\x01\0\0:\x01\0\0;\x01\0\0<\x01\0\0=\x01\0\0@\x01\0\0A\x01\0\0B\x01\0\0C\x01\0\0G\x01\0\0K\x01\0\0N\x01\0\0P\x01\0\0R\x01\0\0W\x01\0\0[\x01\0\0\\\x01\0\0]\x01\0\0^\x01\0\0_\x01\0\0b\x01\0\0d\x01\0\0e\x01\0\0i\x01\0\0j\x01\0\0l\x01\0\0s\x01\0\0v\x01\0\0w\x01\0\0y\x01\0\0z\x01\0\0{\x01\0\0}\x01\0\0~\x01\0\0\x7F\x01\0\0\x80\x01\0\0\x81\x01\0\0\x82\x01\0\0\x83\x01\0\0\x85\x01\0\0\x87\x01\0\0\x88\x01\0\0\x89\x01\0\0\x8A\x01\0\0\x8B\x01\0\0\x8C\x01\0\0\x8D\x01\0\0\x8E\x01\0\0\x91\x01\0\0\x95\x01\0\0\x9B\x01\0\0\x9C\x01\0\0\x9D\x01\0\0\x9E\x01\0\0\xA1\x01\0\0\xA2\x01\0\0\xA3\x01\0\0\xA6\x01\0\0\xA8\x01\0\0\xA9\x01\0\0\xAB\x01\0\0\xAD\x01\0\0\xAE\x01\0\0\xB2\x01\0\0\xB3\x01\0\0\xB4\x01\0\0\xB5\x01\0\0\xB6\x01\0\0\xBD\x01\0\0\xBE\x01\0\0\xBF\x01\0\0\xC0\x01\0\0\xC1\x01\0\0\xC2\x01\0\0\xC3\x01\0\0\xC4\x01\0\0\xC5\x01\0\0\xC6\x01\0\0\xC7\x01\0\0\xC8\x01\0\0\xC9\x01\0\0\xCA\x01\0\0\xCB\x01\0\0\xCC\x01\0\0\xCD\x01\0\0\xCF\x01\0\0\xD0\x01\0\0\xD2\x01\0\0\xD3\x01\0\0\xD4\x01\0\0\xD5\x01\0\0\xD9\x01\0\0\xDC\x01\0\0\xDD\x01\0\0\xDE\x01\0\0\xE0\x01\0\0\xE1\x01\0\0\xE2\x01\0\0\xE3\x01\0\0\xE4\x01\0\0\xE7\x01\0\0\xEA\x01\0\0\xEB\x01\0\0\xEC\x01\0\0\xF0\x01\0\0\xF3\x01\0\0\xF4\x01\0\0\xF8\x01\0\0\xFB\x01\0\0\xFE\x01\0\0\xFF\x01\0\0\0\x02\0\0\x01\x02\0\0\x02\x02\0\0\x03\x02\0\0\x04\x02\0\0\x07\x02\0\0\x08\x02\0\0\t\x02\0\0\n\x02\0\0\x0C\x02\0\0\r\x02\0\0\x0E\x02\0\0\x0F\x02\0\0\x10\x02\0\0\x11\x02\0\0\x14\x02\0\0\x15\x02\0\0\x16\x02\0\0\x17\x02\0\0\x18\x02\0\0\x19\x02\0\0\x1A\x02\0\0\x1B\x02\0\0\x1C\x02\0\0\x1D\x02\0\0\x1E\x02\0\0 \x02\0\0#\x02\0\0&\x02\0\0'\x02\0\0(\x02\0\0)\x02\0\0*\x02\0\0-\x02\0\0.\x02\0\0/\x02\0\x000\x02\0\x001\x02\0\x003\x02\0\x004\x02\0\x007\x02\0\09\x02\0\0:\x02\0\0;\x02\0\0?\x02\0\0@\x02\0\0A\x02\0\0B\x02\0\0C\x02\0\0E\x02\0\0J\x02\0\0K\x02\0\0L\x02\0\0N\x02\0\0P\x02\0\0S\x02\0\0U\x02\0\0V\x02\0\0W\x02\0\0X\x02\0\0Y\x02\0\0[\x02\0\0\\\x02\0\0]\x02\0\0`\x02\0\0c\x02\0\0d\x02\0\0g\x02\0\0i\x02\0\0k\x02\0\0o\x02\0\0q\x02\0\0s\x02\0\0t\x02\0\0w\x02\0\0y\x02\0\0z\x02\0\0|\x02\0\0~\x02\0\0\x81\x02\0\0\x85\x02\0\0\x87\x02\0\0\x88\x02\0\0\x89\x02\0\0\x8D\x02\0\0\x8F\x02\0\0\x90\x02\0\0\x91\x02\0\0\x92\x02\0\0\x93\x02\0\0\x94\x02\0\0\x95\x02\0\0\x96\x02\0\0\x97\x02\0\0\x98\x02\0\0\x99\x02\0\0\x9A\x02\0\0\x9B\x02\0\0\x9C\x02\0\0\x9D\x02\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0pY\xAE\0\0\0\0\0\0\0\0\0\0\0\0\0\xF8]?\x01\x84eB\x01x\xA0O\x01\\2R\x01 \xA3w\x01\xFC\xBB\x82\x01\xF0Y\x87\x01\xA0\xE2\x8A\x01\xF4M\x8F\x01\xC0\xBA\x92\x01\x01X\x97\x01\xEC\xE0\x9A\x01\x81W\x9F\x01l\xE0\xA2\x01\x01W\xA7\x01\xC0\xCF\xAA\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x14\xF2b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\xF3\xAE\0\0\0\0\x000\xF3\xAE\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\0\x18\xD4\xA9\0pM\xAB\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\0p\xA4\xAE\0\0\0\0\0\x18\x18\xA2\0\x10\xDA\xAB\0\x94\xC7\xEE\0\x94\x1E\xF2\0T-\x14\x01\xF0b\x15\x01Xf1\x01\xF08?\x01\0\0\0\0\xB0\xF2\xB6\0P\xC5\x16\x01\0\0\0\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\x000\xF3\xAE\0\0\0\0\x000\xF3\xAE\0\xF42\x14\x01\xB0v\x14\x01\0\0\0\0\x18\xD4\xA9\0pM\xAB\0T-\x14\x01\xF0b\x15\x01\0\0\0\0\x10\x9E\x14\x01\0\0\0\0\x10\xF9n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xC8\x92Y\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0p\xD2\xAD\0\0\0\0\0\0\0\0\0\0\0\0\08\xDC\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0P`\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\xCE4\x01\xD0\xFB_\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\xCE4\x01\xD0\xFB_\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xB0\xCE4\x01\0\0\0\0\0\0\0\0\xF6k\x8E\0\0\0\0\0\0\0\0\0$|\xAA\0\x80\xE8J\x01\xC8\xB0g\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x18\x9Aj\x01\0\0\0\0\0\0\0\0\xD1~\x92\0\x99\x1B\x97\0\0\0\0\0\0\0\0\0\xC8e\xEF\0\x84e\xF7\0\0\0\0\0\0\0\0\0\x84e\xF7\0\0\xC8\xFA\0\xE4\x89'\x01@v*\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@f\xEF\0\x84e\xF7\0l\x8C\xF7\0<\xC8\xFA\0\x9C\xAE\x1E\0\x04\xF9\x97\x01\0\0\0\0\x9C]\x15\0\0\0\0\0\x84e\xF7\0\0\xC8\xFA\0\0\0\0\0x\xD3J\0\0\0\0\0\x04\xF9\x97\x01\0\0\0\0\\\xAF\x12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,\xAD&\0He\xF7\0(*\xF8\0\0\0\0\0\x04\x9F>\0d\xC5N\0@\xECZ\0\0\0\0\0\xACi\x80\0\0\0\0\0\0\0\0\0\xC4U\x9A\0\0\0\0\0\0\0\0\0\x9Cm2\0\0\0\0\0\0\0\0\0\x80\xFEq\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x88\xA6\xD0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\x10\xAE\xAA\0\0\0\0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\xB4\xA7\xD0\0\0\0\0\0<<\xB3\x01\0\0\0\0\x183Z\0\\X\xB3\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xE8\x96\xF8\0\0\0\0\0|\x1F(\0\0\0\0\0\0\0\0\0\x88\xA6\xD0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xE0p\x90\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x10\xD8\xAD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xA4\x19n\x01\xE4\xF0\x83\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xB41\xB0\0\xC8\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\xB41\xB0\0\x8C\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0P\x88\x17\x01\xF8\xAD\xB2\x01\xC8\x88\x17\x01\xF8\xAD\xB2\x01\x8C\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\xB41\xB0\0\x8C\x88\x17\x01X\xFF\x88\x01\xF8\xAD\xB2\x01\0\0\0\0\xF01\xB0\0\xC8\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0V\xD5\xD3\0\xD62#\x01\0\0\0\0\r\xB3\x12\0\0\0\0\0\0\0\0\0\xC4U\x9A\0|\xA0\xE2\0\x9Cd\xEF\0\0\0\0\0\0\0\0\0\xC4U\x9A\0\0\0\0\0\xE8M`\0D6\xA3\0(\xA6\xD6\0\xC8\xC1\xDE\0\xC0\xF5W\x01\xE0\xA0_\x01\0\0\0\0\x80\xFEq\0Dh\x80\0\0\0\0\0\0\0\0\0\x0CA\xA3\0\0\0\0\0\0\0\0\0\0\0\0\0p\xB3\xBD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xC0{\xF0\0\0\0\0\0\xE8\x96\xF8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01(\xA6\xA8\x01\0\0\0\0\x80.`\0\x8Ceh\0\xA4?\xDF\0hf\xE5\0\xC0\xD4i\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80.`\0\xA4\x03g\0\0\0\0\0\0\0\0\0\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01\0\0\0\0|\x12C\x01\0\0\0\0\0\0\0\0\x80L`\0\0\0\0\0\x80L`\0\0\0\0\0\0\0\0\0\x88>\xA2\0\xA8X\xC2\0\xE8\xB4\x7F\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0h\xB9\x1A\0,#)\08\x8F\xB0\0\xECk\xB6\0\x08\x99\xB8\0\xEC\xB2\xD8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\xDC\t\0\0\0\0\0\0\0\0\0\x10\xE8R\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\r6\0\xDC{\xB6\0|\xA1\xD2\0\0\0\0\0\xF8{\xB8\0\x89\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0d\x99j\x01D\xBF\x82\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\n\xAE\0\0\0\0\0\0\0\0\0$\xD62\0\xC0u\xF6\0\0\0\0\0\xB0\x18\xAF\0\0\0\0\0\0\0\0\0\0\0\0\0l\"D\0\xCC\xC7z\0,\xA7v\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H|\xA4\0\0\0\0\0\x84|\xA4\0\x0C?\xC3\0\xFC\xA0\xDA\0`\x0Ec\x01\0\0\0\0\0\0\0\0\0\0\0\0\x10\xF9n\0\0\0\0\0\xF8\xA6o\0\0\0\0\0\xE47 \0\xA4\xAD&\0\0\0\0\0\xBC\xA6o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xD4\xF8n\0\0\0\0\0\0\0\0\0\0\0\0\0\xB8\xD2V\0\xBC\xA6o\0\0\0\0\0D\x1B\xAF\0\xA4\xEC\"\x01\0\0\0\0\0\0\0\0\xE47 \0\xA4\xAD&\0\0\0\0\0d\xAE\x1A\0\0\0\0\0\x84e\xF7\0\0\0\0\0\xD8\xD4o\x01\xB8\xFA\x87\x01\xD8\xAB\x89\x01\0\0\0\0\0\x1B\xB7\0\0\0\0\0@d\x0F\x01\0\0\0\0\0\0\0\0\xA4\xEC\"\x01\xC4\xB0/\x01\0\0\0\0\xBC\xA6o\0\0\0\0\0\0\0\0\0\xBC\xA6o\0\0\0\0\0\xA4\xEC\"\x01\0\0\0\0\xA4\xEC\"\x01@v*\x01\0\0\0\0\x84\xD3>\0\xA4\xEC\"\x01\xC4\xB0/\x01\0\0\0\0\xE0\xD6G\x01\xBC\xA6o\0\0\0\0\0\0\0\0\0xG^\08Gb\08\xDD\xAD\0\0\0\0\08\xDD\xAD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\xB2+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01euce\x01gulf\x01afgh\x01atla\x01atla\x01euce\0\0\0\0\0\x01arme\x01atla\x01afwe\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01davi\x01dumo\x01maws\x01neze\x01arge\x01chil\x01roth\x01syow\x01mgmt\x01vost\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\0\0\0\0\0\x01samo\x01euce\x01auce\x01auce\x01auea\x01auce\x01aucw\x01auea\x01auea\x01auea\x01loho\x01auea\x01auea\x01auwe\x01auea\x01atla\0\0\0\0\0\x01azer\x01euce\x01atla\0\0\0\0\0\x01bang\x01euce\x01mgmt\x01euea\x01gulf\x01arab\x01afce\x01afwe\x01atla\x01brun\x01boli\x01atla\x01bras\x01bras\x01amaz\x01amaz\x01amaz\x01acre\x01amaz\x01acre\x01noro\x01bras\x01amaz\x01bras\x01amaz\x01acre\x01amaz\x01acre\x01bras\x01bras\x01bras\x01amaz\x01bras\x01amea\x01indi\x01bhut\x01afce\x01mosc\x01euea\x01eufe\x01mosc\x01amce\x01ammo\x01ammo\x01ampa\x01ammo\x01atla\x01atla\0\0\0\0\0\x01atla\x01atla\x01amea\x01amce\x01amea\x01atla\x01amce\x01amea\x01amce\x01amea\x01amce\x01amce\x01newf\x01amea\x01ampa\x01amce\x01atla\x01ammo\x01amce\x01amea\x01amce\x01ammo\x01ampa\x01yuko\x01ampa\x01ammo\x01amce\x01amea\x01amce\x01ampa\x01ammo\x01ampa\x01yuko\x01ammo\x01amce\x01amea\x01coco\x01afce\x01afwe\x01afwe\x01afwe\x01euce\x01mgmt\x01cook\x01east\x01chil\x01chil\x01afwe\x01chin\0\0\0\0\0\x01colo\x01amce\x01cuba\x01cave\x01chri\x01euea\x01euea\x01euce\x01euce\x01euce\x01afea\x01euce\x01atla\0\0\0\0\0\x01atla\x01amea\x01atla\x01euwe\x01euce\x01euwe\x01euce\x01ecua\x01gala\x01ecua\x01mosc\x01euea\x01euea\0\0\0\0\0\x01euwe\x01afea\x01euwe\x01euce\x01euwe\x01euce\x01afea\x01euea\x01euea\x01fiji\x01falk\x01kosr\x01pona\x01truk\x01euwe\x01euce\x01afwe\x01isra\x01euea\0\0\0\0\0\x01mgmt\x01atla\0\0\0\0\0\x01geor\x01frgu\0\0\0\0\0\x01mgmt\x01mgmt\x01euce\x01grwe\x01mgmt\x01grwe\x01gree\0\0\0\0\0\x01grea\x01gree\x01atla\x01mgmt\x01mgmt\x01mgmt\x01atla\x01atla\x01atla\x01afwe\x01euea\x01soge\x01amce\x01guam\x01cham\0\0\0\0\0\x01mgmt\x01guya\x01isra\x01euea\x01hoko\x01amce\x01euce\x01amea\x01euce\x01inea\x01inwe\x01ince\x01ince\x01inwe\0\0\0\0\0\x01mgmt\0\0\0\0\0\x01mgmt\x01indi\x01inoc\x01arab\x01iran\x01mgmt\x01euce\x01isra\0\0\0\0\0\x01mgmt\x01amea\x01euea\x01japa\x01afea\0\0\0\0\0\x01kyrg\x01indo\x01liis\x01phis\x01giis\x01afea\x01atla\x01kore\x01pyon\x01kore\x01kore\x01arab\x01amea\0\0\0\0\0\x01aqta\x01kawe\x01kaza\0\0\0\0\0\x01aqto\x01kawe\x01kaza\x01alam\x01kaea\x01kaza\x01kawe\x01kaza\x01kaea\x01kaza\0\0\0\0\0\x01qyzy\x01kaea\x01kawe\x01kaza\0\0\0\0\0\0\0\0\0\0\x01kawe\x01kaza\x01indo\x01euea\x01atla\x01euce\x01indi\x01lank\x01indi\0\0\0\0\0\x01mgmt\x01afso\x01mosc\x01euea\x01euce\x01euea\x01euce\x01mosc\x01euea\x01euea\x01euce\x01euea\x01euce\x01euea\x01euce\x01euea\x01euwe\x01euce\x01euwe\x01euce\x01mosc\x01euea\x01euce\x01afea\0\0\0\0\0\x01mais\x01mais\x01euce\x01mgmt\x01myan\x01hovd\x01mong\x01maca\x01chin\x01noma\x01cham\x01atla\x01mgmt\x01atla\x01euce\x01maur\x01mald\x01afce\x01amce\x01mepa\x01amce\x01amce\x01mepa\x01amce\x01ammo\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01mepa\x01amce\x01amce\x01amce\x01amea\x01amce\x01amce\x01mepa\x01amce\x01ammo\x01amce\x01ammo\x01amce\x01ampa\0\0\0\0\0\x01mala\0\0\0\0\0\x01mala\x01afce\x01afso\x01afce\x01afwe\x01afce\x01neca\x01afwe\x01norf\x01afwe\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01euce\x01euce\x01nepa\x01naur\x01niue\x01neze\x01chat\x01gulf\x01amea\x01peru\x01gamb\x01marq\x01tahi\x01pang\x01pang\x01phil\0\0\0\0\0\x01paki\x01euce\x01atla\x01pimi\x01pitc\x01atla\x01euwe\x01euce\x01euwe\x01euce\x01euwe\x01azor\x01euwe\x01azor\x01pala\x01para\x01gulf\x01arab\x01reun\x01euea\x01euce\x01mosc\x01yaku\x01irku\x01yaku\x01anad\x01maga\x01anad\x01maga\x01irku\x01mosc\x01euea\x01eufe\x01euea\x01yaku\x01vlad\x01yaku\x01kras\0\0\0\0\0\x01mosc\x01euea\x01sama\x01mosc\x01euea\x01mosc\x01kras\x01novo\x01kras\x01omsk\x01novo\x01kamc\x01mosc\x01maga\x01mosc\x01yaku\x01maga\x01vlad\x01sakh\x01volg\x01vlad\0\0\0\0\0\x01yeka\x01yaku\x01afce\x01arab\x01solo\x01seyc\x01afce\x01afea\x01afce\x01euce\x01sing\x01mgmt\x01euce\x01euce\x01euce\x01mgmt\x01euce\x01mgmt\x01afea\0\0\0\0\0\x01suri\x01afce\x01afea\x01afce\x01mgmt\x01afwe\x01mgmt\x01amce\x01atla\x01euea\x01afso\x01amea\x01atla\x01amea\x01afwe\x01frso\x01mgmt\x01indo\0\0\0\0\0\x01taji\x01toke\x01eati\x01ince\x01eati\0\0\0\0\0\x01turk\x01euce\x01tong\x01euea\0\0\0\0\0\x01euea\0\0\0\0\0\x01atla\x01tuva\x01taip\x01afea\x01mosc\x01euea\x01mosc\x01euea\x01mosc\x01euea\x01mosc\x01afea\x01wake\0\0\0\0\0\x01samo\0\0\0\0\0\x01haal\x01amea\x01amce\x01amea\0\0\0\0\0\x01alas\x01ammo\x01amce\x01ammo\x01amea\0\0\0\0\0\x01haal\x01amea\x01amea\x01ampa\x01ampa\x01alas\x01amce\x01amea\x01amce\x01ampa\x01amea\x01amce\x01amea\x01amea\x01amce\x01amce\x01amea\x01ampa\x01alas\x01ampa\x01alas\x01ammo\x01amce\x01ammo\x01amce\x01amea\x01amea\x01amce\x01amea\0\0\0\0\0\x01alas\x01ammo\x01ampa\x01alas\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01ammo\x01amce\x01alas\x01urug\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01uzbe\0\0\0\0\0\x01uzbe\x01euce\x01atla\x01vene\x01atla\x01atla\x01indo\x01vanu\x01wall\x01apia\x01arab\x01afea\x01afso\x01afce\x01afce") }) }); } #[clippy::msrv = "1.71.1"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { if req.id.locale.is_default() { Ok(icu_provider::DataResponse { payload: icu_provider::DataPayload::from_static_ref(Self::SINGLETON_METAZONE_PERIOD_V1_MARKER), metadata: Default::default() }) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } @@ -35,7 +35,7 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , ITER) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::IterableDataProvider for $provider { + impl icu_provider::IterableDataProvider for $provider { fn iter_ids(&self) -> Result>, icu_provider::DataError> { Ok([Default::default()].into_iter().collect()) } @@ -44,12 +44,12 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , DRY) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::DryDataProvider for $provider { + impl icu_provider::DryDataProvider for $provider { fn dry_load(&self, req: icu_provider::DataRequest) -> Result { if req.id.locale.is_default() { Ok(Default::default()) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } @@ -57,17 +57,17 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , DRY , ITER) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::DryDataProvider for $provider { + impl icu_provider::DryDataProvider for $provider { fn dry_load(&self, req: icu_provider::DataRequest) -> Result { if req.id.locale.is_default() { Ok(Default::default()) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } #[clippy::msrv = "1.71.1"] - impl icu_provider::IterableDataProvider for $provider { + impl icu_provider::IterableDataProvider for $provider { fn iter_ids(&self) -> Result>, icu_provider::DataError> { Ok([Default::default()].into_iter().collect()) } diff --git a/provider/data/datetime/data/mod.rs b/provider/data/datetime/data/mod.rs index b59e9db22e3..a63daa29b0e 100644 --- a/provider/data/datetime/data/mod.rs +++ b/provider/data/datetime/data/mod.rs @@ -46,6 +46,7 @@ include!("time_zone_essentials_v1_marker.rs.data"); include!("metazone_generic_names_long_v1_marker.rs.data"); include!("metazone_generic_names_short_v1_marker.rs.data"); include!("locations_v1_marker.rs.data"); +include!("metazone_period_v1_marker.rs.data"); include!("metazone_specific_names_long_v1_marker.rs.data"); include!("metazone_specific_names_short_v1_marker.rs.data"); /// Marks a type as a data provider. You can then use macros like @@ -124,6 +125,7 @@ macro_rules! impl_data_provider { impl_metazone_generic_names_long_v1_marker!($provider); impl_metazone_generic_names_short_v1_marker!($provider); impl_locations_v1_marker!($provider); + impl_metazone_period_v1_marker!($provider); impl_metazone_specific_names_long_v1_marker!($provider); impl_metazone_specific_names_short_v1_marker!($provider); }; @@ -182,6 +184,7 @@ macro_rules! impl_any_provider { h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), + h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), _ => Err(icu_provider::DataErrorKind::MarkerNotFound.with_req(marker, req)), diff --git a/provider/data/datetime/fingerprints.csv b/provider/data/datetime/fingerprints.csv index 341596b80e2..5147b8c38a9 100644 --- a/provider/data/datetime/fingerprints.csv +++ b/provider/data/datetime/fingerprints.csv @@ -35814,6 +35814,7 @@ time_zone/locations@1, zh-Hant, 9144B, 8985B, 26eed758c6fb3d8d time_zone/locations@1, zh-MO, -> zh-HK time_zone/locations@1, zh-SG, 9247B, 9088B, dbf3a8f8eb62d828 time_zone/locations@1, zu, 9086B, 8927B, cebb6ba6c35f2d98 +time_zone/metazone_period@1, , 11097B, 11009B, dcfa50fb39ebd549 time_zone/specific_long@1, , 948B, 190 identifiers time_zone/specific_long@1, , 1638778B, 1605415B, 185 unique payloads time_zone/specific_long@1, af, 6872B, 6692B, 92b73e3a6b592d73 diff --git a/provider/data/timezone/stubdata/metazone_period_v1_marker.rs.data b/provider/data/datetime/stubdata/metazone_period_v1_marker.rs.data similarity index 94% rename from provider/data/timezone/stubdata/metazone_period_v1_marker.rs.data rename to provider/data/datetime/stubdata/metazone_period_v1_marker.rs.data index 61f472883ec..bb597013143 100644 --- a/provider/data/timezone/stubdata/metazone_period_v1_marker.rs.data +++ b/provider/data/datetime/stubdata/metazone_period_v1_marker.rs.data @@ -16,18 +16,18 @@ macro_rules! __impl_metazone_period_v1_marker { #[clippy::msrv = "1.71.1"] impl $provider { #[doc(hidden)] - pub const SINGLETON_METAZONE_PERIOD_V1_MARKER: &'static ::DataStruct = &icu::timezone::provider::MetazonePeriodV1(unsafe { + pub const SINGLETON_METAZONE_PERIOD_V1_MARKER: &'static ::DataStruct = &icu::datetime::provider::time_zones::MetazonePeriodV1(unsafe { #[allow(unused_unsafe)] zerovec::ZeroMap2d::from_parts_unchecked(unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"adalv\0\0\0aedxb\0\0\0afkbl\0\0\0aganu\0\0\0aiaxa\0\0\0altia\0\0\0amevn\0\0\0ancur\0\0\0aolad\0\0\0aqcas\0\0\0aqdav\0\0\0aqddu\0\0\0aqmaw\0\0\0aqmcm\0\0\0aqplm\0\0\0aqrot\0\0\0aqsyw\0\0\0aqtrl\0\0\0aqvos\0\0\0arbue\0\0\0arcor\0\0\0arctc\0\0\0arirj\0\0\0arjuj\0\0\0arluq\0\0\0armdz\0\0\0arrgl\0\0\0arsla\0\0\0artuc\0\0\0aruaq\0\0\0arush\0\0\0asppg\0\0\0atvie\0\0\0auadl\0\0\0aubhq\0\0\0aubne\0\0\0audrw\0\0\0aueuc\0\0\0auhba\0\0\0auldc\0\0\0auldh\0\0\0aumel\0\0\0aumqi\0\0\0auper\0\0\0ausyd\0\0\0awaua\0\0\0azbak\0\0\0basjj\0\0\0bbbgi\0\0\0bddac\0\0\0bebru\0\0\0bfoua\0\0\0bgsof\0\0\0bhbah\0\0\0bibjm\0\0\0bjptn\0\0\0bmbda\0\0\0bnbwn\0\0\0bolpb\0\0\0bqkra\0\0\0braux\0\0\0brbel\0\0\0brbvb\0\0\0brcgb\0\0\0brcgr\0\0\0brern\0\0\0brfen\0\0\0brfor\0\0\0brmao\0\0\0brmcz\0\0\0brpvh\0\0\0brrbr\0\0\0brrec\0\0\0brsao\0\0\0brssa\0\0\0brstm\0\0\0bsnas\0\0\0btthi\0\0\0bwgbe\0\0\0bymsq\0\0\0bzbze\0\0\0cacfq\0\0\0caedm\0\0\0cafne\0\0\0caglb\0\0\0cagoo\0\0\0cahal\0\0\0caiql\0\0\0camon\0\0\0careb\0\0\0careg\0\0\0casjf\0\0\0cator\0\0\0cavan\0\0\0cawnp\0\0\0caybx\0\0\0caycb\0\0\0cayda\0\0\0caydq\0\0\0cayek\0\0\0cayev\0\0\0cayxy\0\0\0cayyn\0\0\0cayzs\0\0\0cccck\0\0\0cdfbm\0\0\0cdfih\0\0\0cfbgf\0\0\0cgbzv\0\0\0chzrh\0\0\0ciabj\0\0\0ckrar\0\0\0clipc\0\0\0clpuq\0\0\0clscl\0\0\0cmdla\0\0\0cnsha\0\0\0cnurc\0\0\0cobog\0\0\0crsjo\0\0\0cuhav\0\0\0cvrai\0\0\0cxxch\0\0\0cyfmg\0\0\0cynic\0\0\0czprg\0\0\0deber\0\0\0debsngn\0djjib\0\0\0dkcph\0\0\0dmdom\0\0\0dosdq\0\0\0dzalg\0\0\0ecgps\0\0\0ecgye\0\0\0eetll\0\0\0egcai\0\0\0eheai\0\0\0erasm\0\0\0esceu\0\0\0eslpa\0\0\0esmad\0\0\0etadd\0\0\0fihel\0\0\0fimhq\0\0\0fjsuv\0\0\0fkpsy\0\0\0fmksa\0\0\0fmpni\0\0\0fmtkk\0\0\0fotho\0\0\0frpar\0\0\0galbv\0\0\0gazastrpgblon\0\0\0gdgnd\0\0\0getbs\0\0\0gfcay\0\0\0gggci\0\0\0ghacc\0\0\0gigib\0\0\0gldkshvnglgoh\0\0\0globy\0\0\0glthu\0\0\0gmbjl\0\0\0gmt\0\0\0\0\0gncky\0\0\0gpbbr\0\0\0gpmsb\0\0\0gpsbh\0\0\0gqssg\0\0\0grath\0\0\0gsgrv\0\0\0gtgua\0\0\0gugum\0\0\0gwoxb\0\0\0gygeo\0\0\0hebron\0\0hkhkg\0\0\0hntgu\0\0\0hrzag\0\0\0htpap\0\0\0hubud\0\0\0iddjj\0\0\0idjkt\0\0\0idmak\0\0\0idpnk\0\0\0iedub\0\0\0imdgs\0\0\0inccu\0\0\0iodga\0\0\0iqbgw\0\0\0irthr\0\0\0isrey\0\0\0itrom\0\0\0jeruslm\0jesth\0\0\0jmkin\0\0\0joamm\0\0\0jptyo\0\0\0kenbo\0\0\0kgfru\0\0\0khpnh\0\0\0kicxi\0\0\0kipho\0\0\0kitrw\0\0\0kmyva\0\0\0knbas\0\0\0kpfnj\0\0\0krsel\0\0\0kwkwi\0\0\0kygec\0\0\0kzaau\0\0\0kzakx\0\0\0kzala\0\0\0kzguw\0\0\0kzksn\0\0\0kzkzo\0\0\0kzura\0\0\0lavte\0\0\0lbbey\0\0\0lccas\0\0\0livdz\0\0\0lkcmb\0\0\0lrmlw\0\0\0lsmsu\0\0\0ltvno\0\0\0lulux\0\0\0lvrix\0\0\0lytip\0\0\0macas\0\0\0mcmon\0\0\0mdkiv\0\0\0metgd\0\0\0mgtnr\0\0\0mhkwa\0\0\0mhmaj\0\0\0mkskp\0\0\0mlbko\0\0\0mmrgn\0\0\0mnhvd\0\0\0mnuln\0\0\0momfm\0\0\0mpspn\0\0\0mqfdf\0\0\0mrnkc\0\0\0msmni\0\0\0mtmla\0\0\0muplu\0\0\0mvmle\0\0\0mwblz\0\0\0mxchi\0\0\0mxcjs\0\0\0mxcun\0\0\0mxhmo\0\0\0mxmam\0\0\0mxmex\0\0\0mxmid\0\0\0mxmty\0\0\0mxmzt\0\0\0mxoji\0\0\0mxpvr\0\0\0mxtij\0\0\0mykch\0\0\0mykul\0\0\0mzmpm\0\0\0nawdh\0\0\0ncnou\0\0\0nenim\0\0\0nfnlk\0\0\0nglos\0\0\0nimga\0\0\0nlams\0\0\0noosl\0\0\0npktm\0\0\0nrinu\0\0\0nuiue\0\0\0nzakl\0\0\0nzcht\0\0\0ommct\0\0\0papty\0\0\0pelim\0\0\0pfgmr\0\0\0pfnhv\0\0\0pfppt\0\0\0pgpom\0\0\0pgraw\0\0\0phmnl\0\0\0pkkhi\0\0\0plwaw\0\0\0pmmqc\0\0\0pnpcn\0\0\0prsju\0\0\0ptfnc\0\0\0ptlis\0\0\0ptpdl\0\0\0pwror\0\0\0pyasu\0\0\0qadoh\0\0\0rereu\0\0\0robuh\0\0\0rsbeg\0\0\0ruasf\0\0\0ruchita\0rudyr\0\0\0rugdx\0\0\0ruikt\0\0\0rukgd\0\0\0rukhndg\0rukra\0\0\0rukuf\0\0\0rumow\0\0\0runoz\0\0\0ruoms\0\0\0ruovb\0\0\0rupkc\0\0\0rurtw\0\0\0rusred\0\0ruuly\0\0\0ruunera\0ruuus\0\0\0ruvog\0\0\0ruvvo\0\0\0ruyek\0\0\0ruyks\0\0\0rwkgl\0\0\0saruh\0\0\0sbhir\0\0\0scmaw\0\0\0sdkrt\0\0\0sesto\0\0\0sgsin\0\0\0shshn\0\0\0silju\0\0\0sjlyr\0\0\0skbts\0\0\0slfna\0\0\0smsai\0\0\0sndkr\0\0\0somgq\0\0\0srpbm\0\0\0ssjub\0\0\0sttms\0\0\0svsal\0\0\0sxphi\0\0\0sydam\0\0\0szqmn\0\0\0tcgdt\0\0\0tdndj\0\0\0tfpfr\0\0\0tglfw\0\0\0thbkk\0\0\0tjdyu\0\0\0tkfko\0\0\0tldil\0\0\0tmasb\0\0\0tntun\0\0\0totbu\0\0\0trist\0\0\0ttpos\0\0\0tvfun\0\0\0twtpe\0\0\0tzdar\0\0\0uaiev\0\0\0uasip\0\0\0ugkla\0\0\0umawk\0\0\0ummdy\0\0\0usadk\0\0\0usaeg\0\0\0usanc\0\0\0usboi\0\0\0uschi\0\0\0usden\0\0\0usdet\0\0\0ushnl\0\0\0usind\0\0\0usinvev\0usjnu\0\0\0usknx\0\0\0uslax\0\0\0uslui\0\0\0usmnm\0\0\0usmoc\0\0\0usmtm\0\0\0usndcnt\0usndnsl\0usnyc\0\0\0usoea\0\0\0usome\0\0\0usphx\0\0\0ussit\0\0\0ustel\0\0\0uswlz\0\0\0uswsq\0\0\0usxul\0\0\0usyak\0\0\0uymvd\0\0\0uzskd\0\0\0uztas\0\0\0vavat\0\0\0vcsvd\0\0\0veccs\0\0\0vgtov\0\0\0vistt\0\0\0vnsgn\0\0\0vuvli\0\0\0wfmau\0\0\0wsapw\0\0\0yeade\0\0\0ytmam\0\0\0zajnb\0\0\0zmlun\0\0\0zwhre\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01\0\0\0\x02\0\0\0\x03\0\0\0\x04\0\0\0\x05\0\0\0\x06\0\0\0\x08\0\0\0\t\0\0\0\n\0\0\0\x1B\0\0\0\x1C\0\0\0\x1D\0\0\0\x1E\0\0\0\x1F\0\0\0!\0\0\0\"\0\0\0#\0\0\0$\0\0\0%\0\0\0&\0\0\0(\0\0\0,\0\0\x001\0\0\x003\0\0\0<\0\0\0?\0\0\0B\0\0\0D\0\0\0H\0\0\0M\0\0\0O\0\0\0Q\0\0\0R\0\0\0S\0\0\0T\0\0\0U\0\0\0V\0\0\0W\0\0\0X\0\0\0Y\0\0\0[\0\0\0\\\0\0\0]\0\0\0^\0\0\0_\0\0\0`\0\0\0b\0\0\0c\0\0\0d\0\0\0f\0\0\0g\0\0\0h\0\0\0i\0\0\0k\0\0\0l\0\0\0m\0\0\0n\0\0\0o\0\0\0p\0\0\0q\0\0\0r\0\0\0s\0\0\0t\0\0\0u\0\0\0v\0\0\0y\0\0\0z\0\0\0{\0\0\0|\0\0\0}\0\0\0~\0\0\0\x81\0\0\0\x82\0\0\0\x83\0\0\0\x84\0\0\0\x86\0\0\0\x87\0\0\0\x89\0\0\0\x8A\0\0\0\x8E\0\0\0\x8F\0\0\0\x90\0\0\0\x91\0\0\0\x93\0\0\0\x94\0\0\0\x97\0\0\0\x98\0\0\0\x9B\0\0\0\x9C\0\0\0\xA1\0\0\0\xA2\0\0\0\xA3\0\0\0\xA4\0\0\0\xA5\0\0\0\xA6\0\0\0\xA7\0\0\0\xAC\0\0\0\xAE\0\0\0\xB0\0\0\0\xB3\0\0\0\xB5\0\0\0\xB7\0\0\0\xB9\0\0\0\xBA\0\0\0\xBB\0\0\0\xBC\0\0\0\xBD\0\0\0\xBE\0\0\0\xBF\0\0\0\xC0\0\0\0\xC1\0\0\0\xC2\0\0\0\xC3\0\0\0\xC4\0\0\0\xC5\0\0\0\xC6\0\0\0\xC7\0\0\0\xC8\0\0\0\xC9\0\0\0\xCA\0\0\0\xCB\0\0\0\xCC\0\0\0\xCD\0\0\0\xCE\0\0\0\xCF\0\0\0\xD0\0\0\0\xD1\0\0\0\xD2\0\0\0\xD3\0\0\0\xD4\0\0\0\xD5\0\0\0\xD9\0\0\0\xDD\0\0\0\xDF\0\0\0\xE0\0\0\0\xE2\0\0\0\xE3\0\0\0\xE5\0\0\0\xE6\0\0\0\xE8\0\0\0\xE9\0\0\0\xEA\0\0\0\xEB\0\0\0\xEC\0\0\0\xED\0\0\0\xEE\0\0\0\xEF\0\0\0\xF0\0\0\0\xF1\0\0\0\xF2\0\0\0\xF3\0\0\0\xF4\0\0\0\xF5\0\0\0\xF7\0\0\0\xF9\0\0\0\xFA\0\0\0\xFC\0\0\0\xFD\0\0\0\xFF\0\0\0\0\x01\0\0\x01\x01\0\0\x03\x01\0\0\x05\x01\0\0\x08\x01\0\0\t\x01\0\0\n\x01\0\0\x0B\x01\0\0\x0C\x01\0\0\r\x01\0\0\x0E\x01\0\0\x0F\x01\0\0\x10\x01\0\0\x11\x01\0\0\x12\x01\0\0\x13\x01\0\0\x15\x01\0\0\x17\x01\0\0\x18\x01\0\0\x1A\x01\0\0\x1B\x01\0\0\x1C\x01\0\0\x1D\x01\0\0\x1E\x01\0\0\x1F\x01\0\0 \x01\0\0!\x01\0\0\"\x01\0\0$\x01\0\0&\x01\0\0(\x01\0\0)\x01\0\0*\x01\0\0+\x01\0\0,\x01\0\0-\x01\0\0.\x01\0\0/\x01\0\x001\x01\0\x002\x01\0\x003\x01\0\x004\x01\0\x005\x01\0\x007\x01\0\08\x01\0\09\x01\0\0:\x01\0\0;\x01\0\0<\x01\0\0=\x01\0\0@\x01\0\0A\x01\0\0B\x01\0\0C\x01\0\0G\x01\0\0K\x01\0\0N\x01\0\0P\x01\0\0R\x01\0\0W\x01\0\0[\x01\0\0\\\x01\0\0]\x01\0\0^\x01\0\0_\x01\0\0b\x01\0\0d\x01\0\0e\x01\0\0i\x01\0\0j\x01\0\0l\x01\0\0s\x01\0\0v\x01\0\0w\x01\0\0y\x01\0\0z\x01\0\0{\x01\0\0}\x01\0\0~\x01\0\0\x7F\x01\0\0\x80\x01\0\0\x81\x01\0\0\x82\x01\0\0\x83\x01\0\0\x85\x01\0\0\x87\x01\0\0\x88\x01\0\0\x89\x01\0\0\x8A\x01\0\0\x8B\x01\0\0\x8C\x01\0\0\x8D\x01\0\0\x8E\x01\0\0\x91\x01\0\0\x95\x01\0\0\x9B\x01\0\0\x9C\x01\0\0\x9D\x01\0\0\x9E\x01\0\0\xA1\x01\0\0\xA2\x01\0\0\xA3\x01\0\0\xA6\x01\0\0\xA8\x01\0\0\xA9\x01\0\0\xAB\x01\0\0\xAD\x01\0\0\xAE\x01\0\0\xB2\x01\0\0\xB3\x01\0\0\xB4\x01\0\0\xB5\x01\0\0\xB6\x01\0\0\xBD\x01\0\0\xBE\x01\0\0\xBF\x01\0\0\xC0\x01\0\0\xC1\x01\0\0\xC2\x01\0\0\xC3\x01\0\0\xC4\x01\0\0\xC5\x01\0\0\xC6\x01\0\0\xC7\x01\0\0\xC8\x01\0\0\xC9\x01\0\0\xCA\x01\0\0\xCB\x01\0\0\xCC\x01\0\0\xCD\x01\0\0\xCF\x01\0\0\xD0\x01\0\0\xD2\x01\0\0\xD3\x01\0\0\xD4\x01\0\0\xD5\x01\0\0\xD9\x01\0\0\xDC\x01\0\0\xDD\x01\0\0\xDE\x01\0\0\xE0\x01\0\0\xE1\x01\0\0\xE2\x01\0\0\xE3\x01\0\0\xE4\x01\0\0\xE7\x01\0\0\xEA\x01\0\0\xEB\x01\0\0\xEC\x01\0\0\xF0\x01\0\0\xF3\x01\0\0\xF4\x01\0\0\xF8\x01\0\0\xFB\x01\0\0\xFE\x01\0\0\xFF\x01\0\0\0\x02\0\0\x01\x02\0\0\x02\x02\0\0\x03\x02\0\0\x04\x02\0\0\x07\x02\0\0\x08\x02\0\0\t\x02\0\0\n\x02\0\0\x0C\x02\0\0\r\x02\0\0\x0E\x02\0\0\x0F\x02\0\0\x10\x02\0\0\x11\x02\0\0\x14\x02\0\0\x15\x02\0\0\x16\x02\0\0\x17\x02\0\0\x18\x02\0\0\x19\x02\0\0\x1A\x02\0\0\x1B\x02\0\0\x1C\x02\0\0\x1D\x02\0\0\x1E\x02\0\0 \x02\0\0#\x02\0\0&\x02\0\0'\x02\0\0(\x02\0\0)\x02\0\0*\x02\0\0-\x02\0\0.\x02\0\0/\x02\0\x000\x02\0\x001\x02\0\x003\x02\0\x004\x02\0\x007\x02\0\09\x02\0\0:\x02\0\0;\x02\0\0?\x02\0\0@\x02\0\0A\x02\0\0B\x02\0\0C\x02\0\0E\x02\0\0J\x02\0\0K\x02\0\0L\x02\0\0N\x02\0\0P\x02\0\0S\x02\0\0U\x02\0\0V\x02\0\0W\x02\0\0X\x02\0\0Y\x02\0\0[\x02\0\0\\\x02\0\0]\x02\0\0`\x02\0\0c\x02\0\0d\x02\0\0g\x02\0\0i\x02\0\0k\x02\0\0o\x02\0\0q\x02\0\0s\x02\0\0t\x02\0\0w\x02\0\0y\x02\0\0z\x02\0\0|\x02\0\0~\x02\0\0\x81\x02\0\0\x85\x02\0\0\x87\x02\0\0\x88\x02\0\0\x89\x02\0\0\x8D\x02\0\0\x8F\x02\0\0\x90\x02\0\0\x91\x02\0\0\x92\x02\0\0\x93\x02\0\0\x94\x02\0\0\x95\x02\0\0\x96\x02\0\0\x97\x02\0\0\x98\x02\0\0\x99\x02\0\0\x9A\x02\0\0\x9B\x02\0\0\x9C\x02\0\0\x9D\x02\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0pY\xAE\0\0\0\0\0\0\0\0\0\0\0\0\0\xF8]?\x01\x84eB\x01x\xA0O\x01\\2R\x01 \xA3w\x01\xFC\xBB\x82\x01\xF0Y\x87\x01\xA0\xE2\x8A\x01\xF4M\x8F\x01\xC0\xBA\x92\x01\x01X\x97\x01\xEC\xE0\x9A\x01\x81W\x9F\x01l\xE0\xA2\x01\x01W\xA7\x01\xC0\xCF\xAA\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x14\xF2b\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x000\xF3\xAE\0\0\0\0\x000\xF3\xAE\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\0\x18\xD4\xA9\0pM\xAB\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\0p\xA4\xAE\0\0\0\0\0\x18\x18\xA2\0\x10\xDA\xAB\0\x94\xC7\xEE\0\x94\x1E\xF2\0T-\x14\x01\xF0b\x15\x01Xf1\x01\xF08?\x01\0\0\0\0\xB0\xF2\xB6\0P\xC5\x16\x01\0\0\0\0\xF42\x14\x01\x10\x9E\x14\x01\0\0\0\x000\xF3\xAE\0\0\0\0\x000\xF3\xAE\0\xF42\x14\x01\xB0v\x14\x01\0\0\0\0\x18\xD4\xA9\0pM\xAB\0T-\x14\x01\xF0b\x15\x01\0\0\0\0\x10\x9E\x14\x01\0\0\0\0\x10\xF9n\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xC8\x92Y\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0p\xD2\xAD\0\0\0\0\0\0\0\0\0\0\0\0\08\xDC\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0P`\x13\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\xCE4\x01\xD0\xFB_\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\xCE4\x01\xD0\xFB_\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xB0\xCE4\x01\0\0\0\0\0\0\0\0\xF6k\x8E\0\0\0\0\0\0\0\0\0$|\xAA\0\x80\xE8J\x01\xC8\xB0g\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x18\x9Aj\x01\0\0\0\0\0\0\0\0\xD1~\x92\0\x99\x1B\x97\0\0\0\0\0\0\0\0\0\xC8e\xEF\0\x84e\xF7\0\0\0\0\0\0\0\0\0\x84e\xF7\0\0\xC8\xFA\0\xE4\x89'\x01@v*\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@f\xEF\0\x84e\xF7\0l\x8C\xF7\0<\xC8\xFA\0\x9C\xAE\x1E\0\x04\xF9\x97\x01\0\0\0\0\x9C]\x15\0\0\0\0\0\x84e\xF7\0\0\xC8\xFA\0\0\0\0\0x\xD3J\0\0\0\0\0\x04\xF9\x97\x01\0\0\0\0\\\xAF\x12\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0,\xAD&\0He\xF7\0(*\xF8\0\0\0\0\0\x04\x9F>\0d\xC5N\0@\xECZ\0\0\0\0\0\xACi\x80\0\0\0\0\0\0\0\0\0\xC4U\x9A\0\0\0\0\0\0\0\0\0\x9Cm2\0\0\0\0\0\0\0\0\0\x80\xFEq\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x88\xA6\xD0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\x10\xAE\xAA\0\0\0\0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\xB4\xA7\xD0\0\0\0\0\0<<\xB3\x01\0\0\0\0\x183Z\0\\X\xB3\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xE8\x96\xF8\0\0\0\0\0|\x1F(\0\0\0\0\0\0\0\0\0\x88\xA6\xD0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xE0p\x90\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xF8\xAD\x0E\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x10\xD8\xAD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xA4\x19n\x01\xE4\xF0\x83\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xB41\xB0\0\xC8\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\xB41\xB0\0\x8C\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0P\x88\x17\x01\xF8\xAD\xB2\x01\xC8\x88\x17\x01\xF8\xAD\xB2\x01\x8C\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\xB41\xB0\0\x8C\x88\x17\x01X\xFF\x88\x01\xF8\xAD\xB2\x01\0\0\0\0\xF01\xB0\0\xC8\x88\x17\x01\xF8\xAD\xB2\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0V\xD5\xD3\0\xD62#\x01\0\0\0\0\r\xB3\x12\0\0\0\0\0\0\0\0\0\xC4U\x9A\0|\xA0\xE2\0\x9Cd\xEF\0\0\0\0\0\0\0\0\0\xC4U\x9A\0\0\0\0\0\xE8M`\0D6\xA3\0(\xA6\xD6\0\xC8\xC1\xDE\0\xC0\xF5W\x01\xE0\xA0_\x01\0\0\0\0\x80\xFEq\0Dh\x80\0\0\0\0\0\0\0\0\0\x0CA\xA3\0\0\0\0\0\0\0\0\0\0\0\0\0p\xB3\xBD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xC0{\xF0\0\0\0\0\0\xE8\x96\xF8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01(\xA6\xA8\x01\0\0\0\0\x80.`\0\x8Ceh\0\xA4?\xDF\0hf\xE5\0\xC0\xD4i\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80.`\0\xA4\x03g\0\0\0\0\0\0\0\0\0\0\0\0\0\xBC\xC9\xE2\0@\xF8\xA7\x01\0\0\0\0|\x12C\x01\0\0\0\0\0\0\0\0\x80L`\0\0\0\0\0\x80L`\0\0\0\0\0\0\0\0\0\x88>\xA2\0\xA8X\xC2\0\xE8\xB4\x7F\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0h\xB9\x1A\0,#)\08\x8F\xB0\0\xECk\xB6\0\x08\x99\xB8\0\xEC\xB2\xD8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0t\xDC\t\0\0\0\0\0\0\0\0\0\x10\xE8R\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\r6\0\xDC{\xB6\0|\xA1\xD2\0\0\0\0\0\xF8{\xB8\0\x89\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0d\x99j\x01D\xBF\x82\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xEC\n\xAE\0\0\0\0\0\0\0\0\0$\xD62\0\xC0u\xF6\0\0\0\0\0\xB0\x18\xAF\0\0\0\0\0\0\0\0\0\0\0\0\0l\"D\0\xCC\xC7z\0,\xA7v\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0H|\xA4\0\0\0\0\0\x84|\xA4\0\x0C?\xC3\0\xFC\xA0\xDA\0`\x0Ec\x01\0\0\0\0\0\0\0\0\0\0\0\0\x10\xF9n\0\0\0\0\0\xF8\xA6o\0\0\0\0\0\xE47 \0\xA4\xAD&\0\0\0\0\0\xBC\xA6o\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xD4\xF8n\0\0\0\0\0\0\0\0\0\0\0\0\0\xB8\xD2V\0\xBC\xA6o\0\0\0\0\0D\x1B\xAF\0\xA4\xEC\"\x01\0\0\0\0\0\0\0\0\xE47 \0\xA4\xAD&\0\0\0\0\0d\xAE\x1A\0\0\0\0\0\x84e\xF7\0\0\0\0\0\xD8\xD4o\x01\xB8\xFA\x87\x01\xD8\xAB\x89\x01\0\0\0\0\0\x1B\xB7\0\0\0\0\0@d\x0F\x01\0\0\0\0\0\0\0\0\xA4\xEC\"\x01\xC4\xB0/\x01\0\0\0\0\xBC\xA6o\0\0\0\0\0\0\0\0\0\xBC\xA6o\0\0\0\0\0\xA4\xEC\"\x01\0\0\0\0\xA4\xEC\"\x01@v*\x01\0\0\0\0\x84\xD3>\0\xA4\xEC\"\x01\xC4\xB0/\x01\0\0\0\0\xE0\xD6G\x01\xBC\xA6o\0\0\0\0\0\0\0\0\0xG^\08Gb\08\xDD\xAD\0\0\0\0\08\xDD\xAD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\xB2+\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") }, unsafe { zerovec::ZeroVec::from_bytes_unchecked(b"\x01euce\x01gulf\x01afgh\x01atla\x01atla\x01euce\0\0\0\0\0\x01arme\x01atla\x01afwe\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01case\x01auwe\x01davi\x01dumo\x01maws\x01neze\x01arge\x01chil\x01roth\x01syow\x01mgmt\x01vost\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arge\x01arge\x01arge\x01arwe\x01arge\x01arge\x01arwe\x01arge\x01arwe\x01arge\x01arge\x01arge\0\0\0\0\0\x01samo\x01euce\x01auce\x01auce\x01auea\x01auce\x01aucw\x01auea\x01auea\x01auea\x01loho\x01auea\x01auea\x01auwe\x01auea\x01atla\0\0\0\0\0\x01azer\x01euce\x01atla\0\0\0\0\0\x01bang\x01euce\x01mgmt\x01euea\x01gulf\x01arab\x01afce\x01afwe\x01atla\x01brun\x01boli\x01atla\x01bras\x01bras\x01amaz\x01amaz\x01amaz\x01acre\x01amaz\x01acre\x01noro\x01bras\x01amaz\x01bras\x01amaz\x01acre\x01amaz\x01acre\x01bras\x01bras\x01bras\x01amaz\x01bras\x01amea\x01indi\x01bhut\x01afce\x01mosc\x01euea\x01eufe\x01mosc\x01amce\x01ammo\x01ammo\x01ampa\x01ammo\x01atla\x01atla\0\0\0\0\0\x01atla\x01atla\x01amea\x01amce\x01amea\x01atla\x01amce\x01amea\x01amce\x01amea\x01amce\x01amce\x01newf\x01amea\x01ampa\x01amce\x01atla\x01ammo\x01amce\x01amea\x01amce\x01ammo\x01ampa\x01yuko\x01ampa\x01ammo\x01amce\x01amea\x01amce\x01ampa\x01ammo\x01ampa\x01yuko\x01ammo\x01amce\x01amea\x01coco\x01afce\x01afwe\x01afwe\x01afwe\x01euce\x01mgmt\x01cook\x01east\x01chil\x01chil\x01afwe\x01chin\0\0\0\0\0\x01colo\x01amce\x01cuba\x01cave\x01chri\x01euea\x01euea\x01euce\x01euce\x01euce\x01afea\x01euce\x01atla\0\0\0\0\0\x01atla\x01amea\x01atla\x01euwe\x01euce\x01euwe\x01euce\x01ecua\x01gala\x01ecua\x01mosc\x01euea\x01euea\0\0\0\0\0\x01euwe\x01afea\x01euwe\x01euce\x01euwe\x01euce\x01afea\x01euea\x01euea\x01fiji\x01falk\x01kosr\x01pona\x01truk\x01euwe\x01euce\x01afwe\x01isra\x01euea\0\0\0\0\0\x01mgmt\x01atla\0\0\0\0\0\x01geor\x01frgu\0\0\0\0\0\x01mgmt\x01mgmt\x01euce\x01grwe\x01mgmt\x01grwe\x01gree\0\0\0\0\0\x01grea\x01gree\x01atla\x01mgmt\x01mgmt\x01mgmt\x01atla\x01atla\x01atla\x01afwe\x01euea\x01soge\x01amce\x01guam\x01cham\0\0\0\0\0\x01mgmt\x01guya\x01isra\x01euea\x01hoko\x01amce\x01euce\x01amea\x01euce\x01inea\x01inwe\x01ince\x01ince\x01inwe\0\0\0\0\0\x01mgmt\0\0\0\0\0\x01mgmt\x01indi\x01inoc\x01arab\x01iran\x01mgmt\x01euce\x01isra\0\0\0\0\0\x01mgmt\x01amea\x01euea\x01japa\x01afea\0\0\0\0\0\x01kyrg\x01indo\x01liis\x01phis\x01giis\x01afea\x01atla\x01kore\x01pyon\x01kore\x01kore\x01arab\x01amea\0\0\0\0\0\x01aqta\x01kawe\x01kaza\0\0\0\0\0\x01aqto\x01kawe\x01kaza\x01alam\x01kaea\x01kaza\x01kawe\x01kaza\x01kaea\x01kaza\0\0\0\0\0\x01qyzy\x01kaea\x01kawe\x01kaza\0\0\0\0\0\0\0\0\0\0\x01kawe\x01kaza\x01indo\x01euea\x01atla\x01euce\x01indi\x01lank\x01indi\0\0\0\0\0\x01mgmt\x01afso\x01mosc\x01euea\x01euce\x01euea\x01euce\x01mosc\x01euea\x01euea\x01euce\x01euea\x01euce\x01euea\x01euce\x01euea\x01euwe\x01euce\x01euwe\x01euce\x01mosc\x01euea\x01euce\x01afea\0\0\0\0\0\x01mais\x01mais\x01euce\x01mgmt\x01myan\x01hovd\x01mong\x01maca\x01chin\x01noma\x01cham\x01atla\x01mgmt\x01atla\x01euce\x01maur\x01mald\x01afce\x01amce\x01mepa\x01amce\x01amce\x01mepa\x01amce\x01ammo\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01mepa\x01amce\x01amce\x01amce\x01amea\x01amce\x01amce\x01mepa\x01amce\x01ammo\x01amce\x01ammo\x01amce\x01ampa\0\0\0\0\0\x01mala\0\0\0\0\0\x01mala\x01afce\x01afso\x01afce\x01afwe\x01afce\x01neca\x01afwe\x01norf\x01afwe\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01euce\x01euce\x01nepa\x01naur\x01niue\x01neze\x01chat\x01gulf\x01amea\x01peru\x01gamb\x01marq\x01tahi\x01pang\x01pang\x01phil\0\0\0\0\0\x01paki\x01euce\x01atla\x01pimi\x01pitc\x01atla\x01euwe\x01euce\x01euwe\x01euce\x01euwe\x01azor\x01euwe\x01azor\x01pala\x01para\x01gulf\x01arab\x01reun\x01euea\x01euce\x01mosc\x01yaku\x01irku\x01yaku\x01anad\x01maga\x01anad\x01maga\x01irku\x01mosc\x01euea\x01eufe\x01euea\x01yaku\x01vlad\x01yaku\x01kras\0\0\0\0\0\x01mosc\x01euea\x01sama\x01mosc\x01euea\x01mosc\x01kras\x01novo\x01kras\x01omsk\x01novo\x01kamc\x01mosc\x01maga\x01mosc\x01yaku\x01maga\x01vlad\x01sakh\x01volg\x01vlad\0\0\0\0\0\x01yeka\x01yaku\x01afce\x01arab\x01solo\x01seyc\x01afce\x01afea\x01afce\x01euce\x01sing\x01mgmt\x01euce\x01euce\x01euce\x01mgmt\x01euce\x01mgmt\x01afea\0\0\0\0\0\x01suri\x01afce\x01afea\x01afce\x01mgmt\x01afwe\x01mgmt\x01amce\x01atla\x01euea\x01afso\x01amea\x01atla\x01amea\x01afwe\x01frso\x01mgmt\x01indo\0\0\0\0\0\x01taji\x01toke\x01eati\x01ince\x01eati\0\0\0\0\0\x01turk\x01euce\x01tong\x01euea\0\0\0\0\0\x01euea\0\0\0\0\0\x01atla\x01tuva\x01taip\x01afea\x01mosc\x01euea\x01mosc\x01euea\x01mosc\x01euea\x01mosc\x01afea\x01wake\0\0\0\0\0\x01samo\0\0\0\0\0\x01haal\x01amea\x01amce\x01amea\0\0\0\0\0\x01alas\x01ammo\x01amce\x01ammo\x01amea\0\0\0\0\0\x01haal\x01amea\x01amea\x01ampa\x01ampa\x01alas\x01amce\x01amea\x01amce\x01ampa\x01amea\x01amce\x01amea\x01amea\x01amce\x01amce\x01amea\x01ampa\x01alas\x01ampa\x01alas\x01ammo\x01amce\x01ammo\x01amce\x01amea\x01amea\x01amce\x01amea\0\0\0\0\0\x01alas\x01ammo\x01ampa\x01alas\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01amce\x01amea\x01ammo\x01amce\x01alas\x01urug\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01uzbe\0\0\0\0\0\x01uzbe\x01euce\x01atla\x01vene\x01atla\x01atla\x01indo\x01vanu\x01wall\x01apia\x01arab\x01afea\x01afso\x01afce\x01afce") }) }); } #[clippy::msrv = "1.71.1"] - impl icu_provider::DataProvider for $provider { - fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { + impl icu_provider::DataProvider for $provider { + fn load(&self, req: icu_provider::DataRequest) -> Result, icu_provider::DataError> { if req.id.locale.is_default() { Ok(icu_provider::DataResponse { payload: icu_provider::DataPayload::from_static_ref(Self::SINGLETON_METAZONE_PERIOD_V1_MARKER), metadata: Default::default() }) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } @@ -35,7 +35,7 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , ITER) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::IterableDataProvider for $provider { + impl icu_provider::IterableDataProvider for $provider { fn iter_ids(&self) -> Result>, icu_provider::DataError> { Ok([Default::default()].into_iter().collect()) } @@ -44,12 +44,12 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , DRY) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::DryDataProvider for $provider { + impl icu_provider::DryDataProvider for $provider { fn dry_load(&self, req: icu_provider::DataRequest) -> Result { if req.id.locale.is_default() { Ok(Default::default()) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } @@ -57,17 +57,17 @@ macro_rules! __impl_metazone_period_v1_marker { ($ provider : ty , DRY , ITER) => { __impl_metazone_period_v1_marker!($provider); #[clippy::msrv = "1.71.1"] - impl icu_provider::DryDataProvider for $provider { + impl icu_provider::DryDataProvider for $provider { fn dry_load(&self, req: icu_provider::DataRequest) -> Result { if req.id.locale.is_default() { Ok(Default::default()) } else { - Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) + Err(icu_provider::DataErrorKind::InvalidRequest.with_req(::INFO, req)) } } } #[clippy::msrv = "1.71.1"] - impl icu_provider::IterableDataProvider for $provider { + impl icu_provider::IterableDataProvider for $provider { fn iter_ids(&self) -> Result>, icu_provider::DataError> { Ok([Default::default()].into_iter().collect()) } diff --git a/provider/data/datetime/stubdata/mod.rs b/provider/data/datetime/stubdata/mod.rs index b59e9db22e3..a63daa29b0e 100644 --- a/provider/data/datetime/stubdata/mod.rs +++ b/provider/data/datetime/stubdata/mod.rs @@ -46,6 +46,7 @@ include!("time_zone_essentials_v1_marker.rs.data"); include!("metazone_generic_names_long_v1_marker.rs.data"); include!("metazone_generic_names_short_v1_marker.rs.data"); include!("locations_v1_marker.rs.data"); +include!("metazone_period_v1_marker.rs.data"); include!("metazone_specific_names_long_v1_marker.rs.data"); include!("metazone_specific_names_short_v1_marker.rs.data"); /// Marks a type as a data provider. You can then use macros like @@ -124,6 +125,7 @@ macro_rules! impl_data_provider { impl_metazone_generic_names_long_v1_marker!($provider); impl_metazone_generic_names_short_v1_marker!($provider); impl_locations_v1_marker!($provider); + impl_metazone_period_v1_marker!($provider); impl_metazone_specific_names_long_v1_marker!($provider); impl_metazone_specific_names_short_v1_marker!($provider); }; @@ -182,6 +184,7 @@ macro_rules! impl_any_provider { h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), + h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), _ => Err(icu_provider::DataErrorKind::MarkerNotFound.with_req(marker, req)), diff --git a/provider/data/timezone/data/mod.rs b/provider/data/timezone/data/mod.rs index cc03811c850..2dbedfe9041 100644 --- a/provider/data/timezone/data/mod.rs +++ b/provider/data/timezone/data/mod.rs @@ -1,7 +1,6 @@ // @generated include!("bcp47_to_iana_map_v1_marker.rs.data"); include!("iana_to_bcp47_map_v3_marker.rs.data"); -include!("metazone_period_v1_marker.rs.data"); include!("zone_offset_period_v1_marker.rs.data"); include!("windows_zones_to_bcp47_map_v1_marker.rs.data"); /// Marks a type as a data provider. You can then use macros like @@ -35,7 +34,6 @@ macro_rules! impl_data_provider { make_provider!($provider); impl_bcp47_to_iana_map_v1_marker!($provider); impl_iana_to_bcp47_map_v3_marker!($provider); - impl_metazone_period_v1_marker!($provider); impl_zone_offset_period_v1_marker!($provider); impl_windows_zones_to_bcp47_map_v1_marker!($provider); }; @@ -49,7 +47,6 @@ macro_rules! impl_any_provider { match marker.path.hashed() { h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), - h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), _ => Err(icu_provider::DataErrorKind::MarkerNotFound.with_req(marker, req)), diff --git a/provider/data/timezone/fingerprints.csv b/provider/data/timezone/fingerprints.csv index 0be79008b72..06a30340ca2 100644 --- a/provider/data/timezone/fingerprints.csv +++ b/provider/data/timezone/fingerprints.csv @@ -1,5 +1,4 @@ time_zone/bcp47_to_iana@1, , 7630B, 7609B, 7efd2629d86e0cdc time_zone/iana_to_bcp47@3, , 9551B, 9509B, ef97860b5f688e6d -time_zone/metazone_period@1, , 11097B, 11009B, dcfa50fb39ebd549 time_zone/offset_period@1, , 13374B, 13286B, 397b18d3f2345411 time_zone/windows_zones_to_bcp47@1, , 8634B, 8591B, 90b7fe3f9cadf5bd diff --git a/provider/data/timezone/stubdata/mod.rs b/provider/data/timezone/stubdata/mod.rs index cc03811c850..2dbedfe9041 100644 --- a/provider/data/timezone/stubdata/mod.rs +++ b/provider/data/timezone/stubdata/mod.rs @@ -1,7 +1,6 @@ // @generated include!("bcp47_to_iana_map_v1_marker.rs.data"); include!("iana_to_bcp47_map_v3_marker.rs.data"); -include!("metazone_period_v1_marker.rs.data"); include!("zone_offset_period_v1_marker.rs.data"); include!("windows_zones_to_bcp47_map_v1_marker.rs.data"); /// Marks a type as a data provider. You can then use macros like @@ -35,7 +34,6 @@ macro_rules! impl_data_provider { make_provider!($provider); impl_bcp47_to_iana_map_v1_marker!($provider); impl_iana_to_bcp47_map_v3_marker!($provider); - impl_metazone_period_v1_marker!($provider); impl_zone_offset_period_v1_marker!($provider); impl_windows_zones_to_bcp47_map_v1_marker!($provider); }; @@ -49,7 +47,6 @@ macro_rules! impl_any_provider { match marker.path.hashed() { h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), - h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), h if h == ::INFO.path.hashed() => icu_provider::DataProvider::::load(self, req).map(icu_provider::DataResponse::wrap_into_any_response), _ => Err(icu_provider::DataErrorKind::MarkerNotFound.with_req(marker, req)), diff --git a/provider/registry/src/lib.rs b/provider/registry/src/lib.rs index e1bfe7428af..e1732126c00 100644 --- a/provider/registry/src/lib.rs +++ b/provider/registry/src/lib.rs @@ -37,12 +37,14 @@ macro_rules! registry( icu::collator::provider::CollationMetadataV1Marker = "collator/meta@1", icu::collator::provider::CollationReorderingV1Marker = "collator/reord@1", icu::collator::provider::CollationSpecialPrimariesV1Marker = "collator/prim@1", + icu::datetime::provider::time_zones::LocationsV1Marker = "time_zone/locations@1", icu::datetime::provider::time_zones::MetazoneGenericNamesLongV1Marker = "time_zone/generic_long@1", icu::datetime::provider::time_zones::MetazoneGenericNamesShortV1Marker = "time_zone/generic_short@1", + icu::datetime::provider::time_zones::MetazonePeriodV1Marker = "time_zone/metazone_period@1", icu::datetime::provider::time_zones::MetazoneSpecificNamesLongV1Marker = "time_zone/specific_long@1", icu::datetime::provider::time_zones::MetazoneSpecificNamesShortV1Marker = "time_zone/specific_short@1", icu::datetime::provider::time_zones::TimeZoneEssentialsV1Marker = "time_zone/essentials@1", - icu::datetime::provider::time_zones::LocationsV1Marker = "time_zone/locations@1", + icu::timezone::provider::ZoneOffsetPeriodV1Marker = "time_zone/offset_period@1", icu::decimal::provider::DecimalSymbolsV1Marker = "decimal/symbols@1", icu::list::provider::AndListV2Marker = "list/and@2", icu::list::provider::OrListV2Marker = "list/or@2", @@ -193,11 +195,9 @@ macro_rules! registry( icu::segmenter::provider::SentenceBreakDataV2Marker = "segmenter/sentence@2", icu::segmenter::provider::WordBreakDataOverrideV1Marker = "segmenter/word/override@1", icu::segmenter::provider::WordBreakDataV2Marker = "segmenter/word@2", - icu::timezone::provider::MetazonePeriodV1Marker = "time_zone/metazone_period@1", icu::timezone::provider::names::Bcp47ToIanaMapV1Marker = "time_zone/bcp47_to_iana@1", icu::timezone::provider::names::IanaToBcp47MapV3Marker = "time_zone/iana_to_bcp47@3", icu::timezone::provider::windows::WindowsZonesToBcp47MapV1Marker = "time_zone/windows_zones_to_bcp47@1", - icu::timezone::provider::ZoneOffsetPeriodV1Marker = "time_zone/offset_period@1", icu::datetime::provider::neo::WeekdayNamesV1Marker = "datetime/names/weekdays@1", icu::datetime::provider::neo::DayPeriodNamesV1Marker = "datetime/names/dayperiods@1", icu::datetime::provider::neo::GluePatternV1Marker = "datetime/patterns/glue@1", diff --git a/provider/source/src/cldr_serde/time_zones/bcp47_tzid.rs b/provider/source/src/cldr_serde/time_zones/bcp47_tzid.rs index 9211899bab7..bb0bf041869 100644 --- a/provider/source/src/cldr_serde/time_zones/bcp47_tzid.rs +++ b/provider/source/src/cldr_serde/time_zones/bcp47_tzid.rs @@ -7,7 +7,7 @@ //! Sample file: //! -use icu::datetime::provider::time_zones::TimeZoneBcp47Id; +use icu::timezone::TimeZoneBcp47Id; use serde::Deserialize; use std::collections::BTreeMap; diff --git a/tutorials/cpp/datetime.cpp b/tutorials/cpp/datetime.cpp index cf4d040991e..3456bfc901b 100644 --- a/tutorials/cpp/datetime.cpp +++ b/tutorials/cpp/datetime.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,21 +62,7 @@ int main() { return 1; } - std::unique_ptr time_zone = CustomTimeZone::from_string("-05:00"); - int32_t offset = time_zone->offset_seconds().value(); - if (offset != -18000) { - std::cout << "GMT offset doesn't parse" << std::endl; - return 1; - } - std::unique_ptr mzcalc = MetazoneCalculator::create(*dp.get()).ok().value(); - std::unique_ptr zocalc = ZoneOffsetCalculator::create(*dp.get()).ok().value(); std::unique_ptr mapper = TimeZoneIdMapper::create(*dp.get()).ok().value(); - time_zone->set_iana_time_zone_id(*mapper.get(), "america/chicago"); - std::string time_zone_id_return = time_zone->time_zone_id(); - if (time_zone_id_return != "uschi") { - std::cout << "Time zone ID does not roundtrip: " << time_zone_id_return << std::endl; - return 1; - } std::string normalized_iana_id = mapper->normalize_iana("America/CHICAGO").ok().value().value(); if (normalized_iana_id != "America/Chicago") { std::cout << "Time zone ID does not normalize: " << normalized_iana_id << std::endl; @@ -98,25 +84,21 @@ int main() { std::cout << "Time zone ID does not roundtrip (fast): " << fast_recovered_iana_id << std::endl; return 1; } - std::unique_ptr local_datetime = IsoDateTime::create(2022, 8, 25, 0, 0, 0, 0).ok().value(); - time_zone->maybe_calculate_metazone(*mzcalc.get(), *local_datetime.get()); - std::string metazone_id_return = time_zone->metazone_id().value(); - if (metazone_id_return != "amce") { - std::cout << "Metazone ID not calculated correctly; got " << metazone_id_return << std::endl; - return 1; - } - time_zone->maybe_calculate_zone_variant(*zocalc.get(), *local_datetime.get()); - if (!time_zone->is_daylight_time()) { - std::cout << "ZoneVariant not calculated correctly" << std::endl; + + std::unique_ptr time_zone = TimeZoneInfo::unknown(); + time_zone->try_set_offset_str("-05:00").ok().value(); + int32_t offset = time_zone->offset_seconds().value(); + if (offset != -18000) { + std::cout << "GMT offset doesn't parse" << std::endl; return 1; } - // Note: The daylight time switch should normally come from TZDB calculations. - time_zone->set_daylight_time(); - std::string zone_variant_return = time_zone->zone_variant().value(); - if (zone_variant_return != "dt") { - std::cout << "Zone variant not calculated correctly; got " << zone_variant_return << std::endl; + time_zone->set_iana_time_zone_id(*mapper.get(), "america/chicago"); + std::string time_zone_id_return = time_zone->time_zone_id(); + if (time_zone_id_return != "uschi") { + std::cout << "Time zone ID does not roundtrip: " << time_zone_id_return << std::endl; return 1; } + time_zone->set_local_time(*date.get()); std::unique_ptr gzdtf = GregorianZonedDateTimeFormatter::create_with_length(*dp.get(), *locale.get(), DateTimeLength::Long).ok().value(); out = gzdtf->format_iso_datetime_with_custom_time_zone(*date.get(), *time_zone.get()); @@ -126,6 +108,8 @@ int main() { return 1; } + time_zone->set_local_time(*any_date->to_iso().get()); + std::unique_ptr zdtf = ZonedDateTimeFormatter::create_with_length(*dp.get(), *locale.get(), DateTimeLength::Long).ok().value(); out = zdtf->format_datetime_with_custom_time_zone(*any_date.get(), *time_zone.get()).ok().value(); std::cout << "Formatted value is " << out << std::endl;