Skip to content

Commit af8dbac

Browse files
authored
Remove VVV time zone format (#5659)
Unblocks #987 See #5658
1 parent 0bf22da commit af8dbac

File tree

5 files changed

+9
-64
lines changed

5 files changed

+9
-64
lines changed

components/datetime/src/format/datetime.rs

-6
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,6 @@ fn select_zone_units(time_zone: ResolvedNeoTimeZoneSkeleton) -> [Option<TimeZone
739739
Some(TimeZoneFormatterUnit::GenericLocation),
740740
Some(TimeZoneFormatterUnit::LocalizedOffsetLong),
741741
],
742-
// 'VVV'
743-
ResolvedNeoTimeZoneSkeleton::City => [
744-
Some(TimeZoneFormatterUnit::ExemplarCity),
745-
Some(TimeZoneFormatterUnit::LocalizedOffsetLong),
746-
None,
747-
],
748742
// 'VVVV'
749743
ResolvedNeoTimeZoneSkeleton::Location => [
750744
Some(TimeZoneFormatterUnit::GenericLocation),

components/datetime/src/format/neo.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,7 @@ impl<C: CldrCalendar, R: DateTimeNamesMarker> TypedDateTimeNames<C, R> {
10281028
/// .include_time_zone_exemplar_city_names()
10291029
/// .unwrap();
10301030
///
1031-
/// // Create a pattern with symbol `VVV`:
1032-
/// let pattern_str = "'Your time zone is:' VVV";
1033-
/// let pattern: DateTimePattern = pattern_str.parse().unwrap();
1034-
///
1035-
/// assert_try_writeable_eq!(
1036-
/// names.with_pattern(&pattern).format(&zone_london_winter),
1037-
/// "Your time zone is: London",
1038-
/// );
1039-
///
1040-
/// // Now try `VVVV`:
1031+
/// // Try `VVVV`:
10411032
/// let pattern_str = "'Your time zone is:' VVVV";
10421033
/// let pattern: DateTimePattern = pattern_str.parse().unwrap();
10431034
///
@@ -2068,9 +2059,8 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
20682059
locale,
20692060
)?;
20702061
}
2071-
// 'VVV..VVVV' (note: `V..VV` are for identifiers only)
2072-
ResolvedNeoTimeZoneSkeleton::City
2073-
| ResolvedNeoTimeZoneSkeleton::Location => {
2062+
// 'VVVV' (note: `V..VV` are for identifiers only)
2063+
ResolvedNeoTimeZoneSkeleton::Location => {
20742064
self.load_time_zone_essentials(zone_essentials_provider, locale)?;
20752065
self.load_fixed_decimal_formatter(
20762066
fixed_decimal_formatter_loader,

components/datetime/src/time_zone.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ use core::fmt;
1313
use fixed_decimal::FixedDecimal;
1414
use icu_decimal::FixedDecimalFormatter;
1515
use icu_timezone::UtcOffset;
16-
use icu_timezone::{TimeZoneBcp47Id, ZoneVariant};
17-
use tinystr::tinystr;
16+
use icu_timezone::ZoneVariant;
1817
use writeable::Writeable;
1918

2019
/// All time zone styles that this crate can format
2120
#[derive(Debug, Copy, Clone)]
2221
pub(crate) enum ResolvedNeoTimeZoneSkeleton {
23-
City,
2422
Location,
2523
GenericShort,
2624
GenericLong,
@@ -44,7 +42,7 @@ pub(crate) enum ResolvedNeoTimeZoneSkeleton {
4442
IsoXXXXX,
4543
// TODO:
4644
// `VV` "America/Los_Angeles"
47-
// Generic Partial Location: "Pacific Time (Los Angeles)"
45+
// `VVV` "Los Angeles"
4846
}
4947

5048
impl ResolvedNeoTimeZoneSkeleton {
@@ -166,7 +164,6 @@ pub(super) enum TimeZoneFormatterUnit {
166164
LocalizedOffsetLong,
167165
LocalizedOffsetShort,
168166
Iso8601(Iso8601Format),
169-
ExemplarCity,
170167
Bcp47Id,
171168
}
172169

@@ -257,7 +254,6 @@ impl FormatTimeZone for TimeZoneFormatterUnit {
257254
ShortLocalizedOffsetFormat.format(sink, input, data_payloads, fdf)
258255
}
259256
Self::Iso8601(iso) => iso.format(sink, input, data_payloads, fdf),
260-
Self::ExemplarCity => ExemplarCityFormat.format(sink, input, data_payloads, fdf),
261257
Self::Bcp47Id => Bcp47IdFormat.format(sink, input, data_payloads, fdf),
262258
}
263259
}
@@ -851,44 +847,6 @@ impl Iso8601Format {
851847
}
852848
}
853849

854-
// Writes the exemplar city associated with this time zone.
855-
// It is only used for pattern in special case and not public to users.
856-
struct ExemplarCityFormat;
857-
858-
impl FormatTimeZone for ExemplarCityFormat {
859-
fn format<W: writeable::PartsWrite + ?Sized>(
860-
&self,
861-
sink: &mut W,
862-
input: &ExtractedInput,
863-
data_payloads: TimeZoneDataPayloadsBorrowed,
864-
_fdf: Option<&FixedDecimalFormatter>,
865-
) -> Result<Result<(), FormatTimeZoneError>, fmt::Error> {
866-
let Some(time_zone_id) = input.time_zone_id else {
867-
return Ok(Err(FormatTimeZoneError::MissingInputField("time_zone_id")));
868-
};
869-
let Some(exemplar_cities) = data_payloads.exemplar_cities else {
870-
return Ok(Err(FormatTimeZoneError::MissingZoneSymbols));
871-
};
872-
873-
let city = exemplar_cities
874-
.0
875-
.get(&time_zone_id)
876-
// Writes the unknown city "Etc/Unknown" for the current locale.
877-
//
878-
// If there is no localized form of "Etc/Unknown" for the current locale,
879-
// returns the "Etc/Unknown" value of the `und` locale as a hard-coded string.
880-
//
881-
// This can be used as a fallback if [`exemplar_city()`](TimeZoneFormatter::exemplar_city())
882-
// is unable to produce a localized form of the time zone's exemplar city in the current locale.
883-
.or_else(|| exemplar_cities.0.get(&TimeZoneBcp47Id(tinystr!(8, "unk"))))
884-
.unwrap_or("Unknown");
885-
886-
sink.write_str(city)?;
887-
888-
Ok(Ok(()))
889-
}
890-
}
891-
892850
// It is only used for pattern in special case and not public to users.
893851
struct Bcp47IdFormat;
894852

components/datetime/src/tz_registry.rs

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ macro_rules! time_zone_style_registry {
5757
(GenericShort, LowerV, One), // 'v'
5858
(GenericLong, LowerV, Wide), // 'vvvv'
5959
(Bcp47Id, UpperV, One), // 'V'
60-
(City, UpperV, Abbreviated), // 'VVV'
6160
(Location, UpperV, Wide), // 'VVVV'
6261
(Isoxxxx, UpperZ, One), // 'Z'
6362
(IsoXXXXX, UpperZ, Narrow), // 'ZZZZZ'

components/datetime/tests/datetime.rs

+4
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,10 @@ fn test_time_zone_patterns() {
525525
} in &test.expectations
526526
{
527527
for pattern_input in patterns {
528+
if pattern_input == "VVV" {
529+
// TODO(#5658): 'VVV' format not yet supported
530+
continue;
531+
}
528532
let parsed_pattern = DateTimePattern::try_from_pattern_str(pattern_input).unwrap();
529533
for expect in expected.iter() {
530534
println!(".");

0 commit comments

Comments
 (0)