diff --git a/components/datetime/src/format/datetime.rs b/components/datetime/src/format/datetime.rs index 0718c682a18..590e58ba05e 100644 --- a/components/datetime/src/format/datetime.rs +++ b/components/datetime/src/format/datetime.rs @@ -739,12 +739,6 @@ fn select_zone_units(time_zone: ResolvedNeoTimeZoneSkeleton) -> [Option [ - Some(TimeZoneFormatterUnit::ExemplarCity), - Some(TimeZoneFormatterUnit::LocalizedOffsetLong), - None, - ], // 'VVVV' ResolvedNeoTimeZoneSkeleton::Location => [ Some(TimeZoneFormatterUnit::GenericLocation), diff --git a/components/datetime/src/format/neo.rs b/components/datetime/src/format/neo.rs index 925284799be..0c307a8ee57 100644 --- a/components/datetime/src/format/neo.rs +++ b/components/datetime/src/format/neo.rs @@ -1028,16 +1028,7 @@ impl TypedDateTimeNames { /// .include_time_zone_exemplar_city_names() /// .unwrap(); /// - /// // Create a pattern with symbol `VVV`: - /// let pattern_str = "'Your time zone is:' VVV"; - /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); - /// - /// assert_try_writeable_eq!( - /// names.with_pattern(&pattern).format(&zone_london_winter), - /// "Your time zone is: London", - /// ); - /// - /// // Now try `VVVV`: + /// // Try `VVVV`: /// let pattern_str = "'Your time zone is:' VVVV"; /// let pattern: DateTimePattern = pattern_str.parse().unwrap(); /// @@ -2068,9 +2059,8 @@ impl RawDateTimeNames { locale, )?; } - // 'VVV..VVVV' (note: `V..VV` are for identifiers only) - ResolvedNeoTimeZoneSkeleton::City - | ResolvedNeoTimeZoneSkeleton::Location => { + // 'VVVV' (note: `V..VV` are for identifiers only) + ResolvedNeoTimeZoneSkeleton::Location => { self.load_time_zone_essentials(zone_essentials_provider, locale)?; self.load_fixed_decimal_formatter( fixed_decimal_formatter_loader, diff --git a/components/datetime/src/time_zone.rs b/components/datetime/src/time_zone.rs index ecb15a2da76..69e5e261527 100644 --- a/components/datetime/src/time_zone.rs +++ b/components/datetime/src/time_zone.rs @@ -13,14 +13,12 @@ use core::fmt; use fixed_decimal::FixedDecimal; use icu_decimal::FixedDecimalFormatter; use icu_timezone::UtcOffset; -use icu_timezone::{TimeZoneBcp47Id, ZoneVariant}; -use tinystr::tinystr; +use icu_timezone::ZoneVariant; use writeable::Writeable; /// All time zone styles that this crate can format #[derive(Debug, Copy, Clone)] pub(crate) enum ResolvedNeoTimeZoneSkeleton { - City, Location, GenericShort, GenericLong, @@ -44,7 +42,7 @@ pub(crate) enum ResolvedNeoTimeZoneSkeleton { IsoXXXXX, // TODO: // `VV` "America/Los_Angeles" - // Generic Partial Location: "Pacific Time (Los Angeles)" + // `VVV` "Los Angeles" } impl ResolvedNeoTimeZoneSkeleton { @@ -166,7 +164,6 @@ pub(super) enum TimeZoneFormatterUnit { LocalizedOffsetLong, LocalizedOffsetShort, Iso8601(Iso8601Format), - ExemplarCity, Bcp47Id, } @@ -257,7 +254,6 @@ impl FormatTimeZone for TimeZoneFormatterUnit { ShortLocalizedOffsetFormat.format(sink, input, data_payloads, fdf) } Self::Iso8601(iso) => iso.format(sink, input, data_payloads, fdf), - Self::ExemplarCity => ExemplarCityFormat.format(sink, input, data_payloads, fdf), Self::Bcp47Id => Bcp47IdFormat.format(sink, input, data_payloads, fdf), } } @@ -851,44 +847,6 @@ impl Iso8601Format { } } -// Writes the exemplar city associated with this time zone. -// It is only used for pattern in special case and not public to users. -struct ExemplarCityFormat; - -impl FormatTimeZone for ExemplarCityFormat { - fn format( - &self, - sink: &mut W, - input: &ExtractedInput, - data_payloads: TimeZoneDataPayloadsBorrowed, - _fdf: Option<&FixedDecimalFormatter>, - ) -> Result, fmt::Error> { - let Some(time_zone_id) = input.time_zone_id else { - return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id"))); - }; - let Some(exemplar_cities) = data_payloads.exemplar_cities else { - return Ok(Err(FormatTimeZoneError::MissingZoneSymbols)); - }; - - let city = exemplar_cities - .0 - .get(&time_zone_id) - // Writes the unknown city "Etc/Unknown" for the current locale. - // - // If there is no localized form of "Etc/Unknown" for the current locale, - // returns the "Etc/Unknown" value of the `und` locale as a hard-coded string. - // - // This can be used as a fallback if [`exemplar_city()`](TimeZoneFormatter::exemplar_city()) - // is unable to produce a localized form of the time zone's exemplar city in the current locale. - .or_else(|| exemplar_cities.0.get(&TimeZoneBcp47Id(tinystr!(8, "unk")))) - .unwrap_or("Unknown"); - - sink.write_str(city)?; - - Ok(Ok(())) - } -} - // It is only used for pattern in special case and not public to users. struct Bcp47IdFormat; diff --git a/components/datetime/src/tz_registry.rs b/components/datetime/src/tz_registry.rs index d4bfdaa2a8e..dc09f90d1c5 100644 --- a/components/datetime/src/tz_registry.rs +++ b/components/datetime/src/tz_registry.rs @@ -57,7 +57,6 @@ macro_rules! time_zone_style_registry { (GenericShort, LowerV, One), // 'v' (GenericLong, LowerV, Wide), // 'vvvv' (Bcp47Id, UpperV, One), // 'V' - (City, UpperV, Abbreviated), // 'VVV' (Location, UpperV, Wide), // 'VVVV' (Isoxxxx, UpperZ, One), // 'Z' (IsoXXXXX, UpperZ, Narrow), // 'ZZZZZ' diff --git a/components/datetime/tests/datetime.rs b/components/datetime/tests/datetime.rs index daff12627ab..9ff7e19904a 100644 --- a/components/datetime/tests/datetime.rs +++ b/components/datetime/tests/datetime.rs @@ -525,6 +525,10 @@ fn test_time_zone_patterns() { } in &test.expectations { for pattern_input in patterns { + if pattern_input == "VVV" { + // TODO(#5658): 'VVV' format not yet supported + continue; + } let parsed_pattern = DateTimePattern::try_from_pattern_str(pattern_input).unwrap(); for expect in expected.iter() { println!(".");