From 933c61cdac14488a2ef4525ac6dd9279eb0edbd8 Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Mon, 15 Jul 2024 18:08:20 -0700 Subject: [PATCH] Start adding ISO8601 style time zone format to neo formatter --- components/datetime/src/neo_skeleton.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/datetime/src/neo_skeleton.rs b/components/datetime/src/neo_skeleton.rs index 687b955c283..01c195bc459 100644 --- a/components/datetime/src/neo_skeleton.rs +++ b/components/datetime/src/neo_skeleton.rs @@ -6,6 +6,8 @@ use crate::options::components; use crate::options::length; +use crate::time_zone::IsoMinutes; +use crate::time_zone::IsoSeconds; #[cfg(feature = "experimental")] use crate::time_zone::ResolvedNeoTimeZoneSkeleton; use crate::DateTimeFormatterOptions; @@ -759,6 +761,17 @@ impl From for NeoComponents { } } +/// Specification of an offset time zone display style. +pub enum OffsetTimeZoneStyle { + /// The localized GMT offset format, e.g., “GMT−8”. + ShortLocalizedGmt, + /// The ISO-8601-style offset format, e.g., “-0800”. + /// + /// Use [`NeoSkeletonLength::Long`] to opt-in to the Unicode variant + /// that includes time separators, e.g., “-08:00”. + Iso8601(IsoMinutes, IsoSeconds), +} + /// Specification of the time zone display style. /// /// Time zone names contribute a lot of data size. For resource-constrained @@ -791,8 +804,8 @@ pub enum NeoTimeZoneStyle { /// /// When unavailable, falls back to [`NeoTimeZoneStyle::Offset`]. SpecificNonLocation, - /// The offset from UTC format, e.g., “GMT−8”. - Offset, + /// The format showing an offset in hours, minutes, and/or seconds from UTC. + Offset(OffsetTimeZoneStyle), } /// A skeleton for formatting a time zone.