Skip to content

Commit

Permalink
gmt -> utc
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Sep 6, 2024
1 parent 8715980 commit d529cbc
Show file tree
Hide file tree
Showing 58 changed files with 909 additions and 912 deletions.
12 changes: 6 additions & 6 deletions components/datetime/src/any/zoned_datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ size_test!(ZonedDateTimeFormatter, zoned_date_time_formatter_size, 6200);
///
/// # Examples
///
/// Using a GMT time zone:
/// Using the UTC time zone:
///
/// ```
/// use icu::calendar::DateTime;
Expand Down Expand Up @@ -82,13 +82,13 @@ size_test!(ZonedDateTimeFormatter, zoned_date_time_formatter_size, 6200);
/// );
/// ```
///
/// Using a non-GMT time zone, specified by id:
/// Using a custom time zone, specified by id:
///
/// ```
/// use icu::calendar::DateTime;
/// use icu::datetime::{options::length, ZonedDateTimeFormatter};
/// use icu::locale::locale;
/// use icu::timezone::{CustomTimeZone, GmtOffset, MetazoneCalculator, ZoneVariant, TimeZoneBcp47Id};
/// use icu::timezone::{CustomTimeZone, UtcOffset, MetazoneCalculator, ZoneVariant, TimeZoneBcp47Id};
/// use tinystr::tinystr;
/// use writeable::assert_writeable_eq;
///
Expand All @@ -108,9 +108,9 @@ size_test!(ZonedDateTimeFormatter, zoned_date_time_formatter_size, 6200);
/// .expect("Failed to construct DateTime.");
/// let any_datetime = datetime.to_any();
///
/// // Create a time zone for America/Chicago at GMT-6:
/// // Create a time zone for America/Chicago at UTC-6:
/// let mut time_zone = CustomTimeZone::new_empty();
/// time_zone.gmt_offset = "-06:00".parse::<GmtOffset>().ok();
/// time_zone.offset = "-06:00".parse().ok();
/// time_zone.time_zone_id = Some(TimeZoneBcp47Id(tinystr!(8, "uschi")));
/// time_zone.zone_variant = Some(ZoneVariant::daylight());
///
Expand Down Expand Up @@ -162,7 +162,7 @@ impl ZonedDateTimeFormatter {
/// options.month = Some(components::Month::Long);
/// options.hour = Some(components::Numeric::Numeric);
/// options.minute = Some(components::Numeric::Numeric);
/// options.time_zone_name = Some(components::TimeZoneName::GmtOffset);
/// options.time_zone_name = Some(components::TimeZoneName::Offset);
///
/// let zdtf = ZonedDateTimeFormatter::try_new_experimental(
/// &locale!("en-u-ca-gregory").into(),
Expand Down
4 changes: 2 additions & 2 deletions components/datetime/src/fields/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,9 @@ field_type!(
/// For example: "Pacific Standard Time"
'z' => LowerZ = 0,
/// Field symbol for any of: the ISO8601 basic format with hours, minutes and optional seconds fields, the
/// long localized GMT format, or the ISO8601 extended format with hours, minutes and optional seconds fields.
/// long localized offset format, or the ISO8601 extended format with hours, minutes and optional seconds fields.
'Z' => UpperZ = 1,
/// Field symbol for the localized GMT format of a time zone.
/// Field symbol for the localized offset format of a time zone.
///
/// For example: "GMT-07:00"
'O' => UpperO = 2,
Expand Down
28 changes: 14 additions & 14 deletions components/datetime/src/format/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::provider::date_time::{
use crate::time_zone::{
Bcp47IdFormat, ExemplarCityFormat, FallbackTimeZoneFormatterUnit, FormatTimeZone,
FormatTimeZoneError, GenericLocationFormat, GenericNonLocationLongFormat,
GenericNonLocationShortFormat, Iso8601Format, LocalizedGmtFormat,
GenericNonLocationShortFormat, Iso8601Format, LocalizedOffsetFormat,
SpecificNonLocationLongFormat, SpecificNonLocationShortFormat, TimeZoneDataPayloadsBorrowed,
TimeZoneFormatterUnit,
};
Expand All @@ -36,7 +36,7 @@ use icu_calendar::AnyCalendarKind;
use icu_decimal::FixedDecimalFormatter;
use icu_plurals::PluralRules;
use icu_provider::DataPayload;
use icu_timezone::{CustomTimeZone, GmtOffset};
use icu_timezone::{CustomTimeZone, UtcOffset};
use writeable::{Part, Writeable};

/// [`FormattedDateTime`] is a intermediate structure which can be retrieved as
Expand Down Expand Up @@ -752,12 +752,12 @@ where
ZS: ZoneSymbols<'data>,
{
fn write_time_zone_missing(
gmt_offset: Option<GmtOffset>,
offset: Option<UtcOffset>,
w: &mut (impl writeable::PartsWrite + ?Sized),
) -> fmt::Result {
match gmt_offset {
Some(gmt_offset) => w.with_part(Part::ERROR, |w| {
Iso8601Format::default_for_fallback().format_infallible(w, gmt_offset)
match offset {
Some(offset) => w.with_part(Part::ERROR, |w| {
Iso8601Format::default_for_fallback().format_infallible(w, offset)
}),
None => w.with_part(Part::ERROR, |w| "{GMT+?}".write_to(w)),
}
Expand All @@ -777,12 +777,12 @@ where
}
Some(custom_time_zone) => match zone_symbols {
None => {
write_time_zone_missing(custom_time_zone.gmt_offset, w)?;
write_time_zone_missing(custom_time_zone.offset, w)?;
Err(DateTimeWriteError::MissingZoneSymbols)
}
Some(zs) => match ResolvedNeoTimeZoneSkeleton::from_field(field_symbol, field_length) {
None => {
write_time_zone_missing(custom_time_zone.gmt_offset, w)?;
write_time_zone_missing(custom_time_zone.offset, w)?;
Err(DateTimeWriteError::UnsupportedField(field))
}
Some(time_zone) => {
Expand All @@ -792,8 +792,8 @@ where
match do_write_zone(units, &zone_input, payloads, w)? {
Ok(()) => Ok(()),
Err(()) => {
write_time_zone_missing(custom_time_zone.gmt_offset, w)?;
// Return an error since GMT data was missing
write_time_zone_missing(custom_time_zone.offset, w)?;
// Return an error since offset data was missing
Err(DateTimeWriteError::MissingZoneSymbols)
}
}
Expand All @@ -809,9 +809,9 @@ fn select_zone_units(time_zone: ResolvedNeoTimeZoneSkeleton) -> [Option<TimeZone
let mut formatters = (
None,
None,
// Friendly Localized GMT Format (requires "essentials" data)
// Friendly Localized offset Format (requires "essentials" data)
Some(TimeZoneFormatterUnit::WithFallback(
FallbackTimeZoneFormatterUnit::LocalizedGmt(LocalizedGmtFormat {}),
FallbackTimeZoneFormatterUnit::LocalizedOffset(LocalizedOffsetFormat {}),
)),
);
match time_zone {
Expand Down Expand Up @@ -856,11 +856,11 @@ fn select_zone_units(time_zone: ResolvedNeoTimeZoneSkeleton) -> [Option<TimeZone
));
}
// `O`
ResolvedNeoTimeZoneSkeleton::GmtShort => {
ResolvedNeoTimeZoneSkeleton::OffsetShort => {
// TODO: For now, use the long format. This should be GMT-8
}
// `OOOO`, `ZZZZ`
ResolvedNeoTimeZoneSkeleton::GmtLong => {
ResolvedNeoTimeZoneSkeleton::OffsetLong => {
// no-op
}
// 'V'
Expand Down
6 changes: 3 additions & 3 deletions components/datetime/src/format/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl<C: CldrCalendar, R: DateTimeNamesMarker> TypedDateTimeNames<C, R> {
/// Includes shared essential patterns for time zone formatting.
///
/// This data should always be loaded when performing time zone formatting.
/// By itself, it allows localized GMT formats.
/// By itself, it allows localized offset formats.
///
/// # Examples
///
Expand Down Expand Up @@ -2082,8 +2082,8 @@ impl<R: DateTimeNamesMarker> RawDateTimeNames<R> {
locale,
)?;
}
ResolvedNeoTimeZoneSkeleton::GmtShort
| ResolvedNeoTimeZoneSkeleton::GmtLong
ResolvedNeoTimeZoneSkeleton::OffsetShort
| ResolvedNeoTimeZoneSkeleton::OffsetLong
| ResolvedNeoTimeZoneSkeleton::Isox
| ResolvedNeoTimeZoneSkeleton::Isoxx
| ResolvedNeoTimeZoneSkeleton::Isoxxx
Expand Down
24 changes: 12 additions & 12 deletions components/datetime/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use icu_calendar::any_calendar::AnyCalendarKind;
use icu_calendar::week::{RelativeUnit, WeekCalculator};
use icu_calendar::Calendar;
use icu_calendar::{AsCalendar, Date, DateTime, Iso};
use icu_timezone::{CustomTimeZone, GmtOffset, ZoneVariant};
use icu_timezone::{CustomTimeZone, UtcOffset, ZoneVariant};

// TODO(#2630) fix up imports to directly import from icu_calendar
pub(crate) use icu_calendar::types::{
Expand Down Expand Up @@ -78,12 +78,12 @@ pub trait IsoTimeInput {

/// Representation of a formattable time zone.
///
/// Only the [`GmtOffset`] is required, since it is the final format fallback.
/// Only the [`UtcOffset`] is required, since it is the final format fallback.
///
/// All data represented in [`TimeZoneInput`] should be locale-agnostic.
pub trait TimeZoneInput {
/// The GMT offset in Nanoseconds.
fn gmt_offset(&self) -> Option<GmtOffset>;
/// The UTC offset.
fn offset(&self) -> Option<UtcOffset>;

/// The IANA time-zone identifier.
fn time_zone_id(&self) -> Option<TimeZoneBcp47Id>;
Expand Down Expand Up @@ -123,7 +123,7 @@ pub(crate) struct ExtractedDateTimeInput {
/// See [`TimeZoneInput`] for documentation on individual fields
#[derive(Debug, Copy, Clone)]
pub(crate) struct ExtractedTimeZoneInput {
gmt_offset: Option<GmtOffset>,
offset: Option<UtcOffset>,
time_zone_id: Option<TimeZoneBcp47Id>,
metazone_id: Option<MetazoneId>,
zone_variant: Option<ZoneVariant>,
Expand Down Expand Up @@ -248,7 +248,7 @@ impl ExtractedTimeZoneInput {
/// Construct given an instance of a [`ZonedDateTimeInput`].
pub(crate) fn extract_from<T: TimeZoneInput>(input: &T) -> Self {
Self {
gmt_offset: input.gmt_offset(),
offset: input.offset(),
time_zone_id: input.time_zone_id(),
metazone_id: input.metazone_id(),
zone_variant: input.zone_variant(),
Expand All @@ -257,7 +257,7 @@ impl ExtractedTimeZoneInput {

pub(crate) fn to_custom_time_zone(self) -> CustomTimeZone {
CustomTimeZone {
gmt_offset: self.gmt_offset,
offset: self.offset,
time_zone_id: self.time_zone_id,
metazone_id: self.metazone_id,
zone_variant: self.zone_variant,
Expand All @@ -268,7 +268,7 @@ impl ExtractedTimeZoneInput {
impl From<CustomTimeZone> for ExtractedTimeZoneInput {
fn from(value: CustomTimeZone) -> Self {
Self {
gmt_offset: value.gmt_offset,
offset: value.offset,
time_zone_id: value.time_zone_id,
metazone_id: value.metazone_id,
zone_variant: value.zone_variant,
Expand Down Expand Up @@ -319,8 +319,8 @@ impl IsoTimeInput for ExtractedDateTimeInput {
}

impl TimeZoneInput for ExtractedTimeZoneInput {
fn gmt_offset(&self) -> Option<GmtOffset> {
self.gmt_offset
fn offset(&self) -> Option<UtcOffset> {
self.offset
}
fn time_zone_id(&self) -> Option<TimeZoneBcp47Id> {
self.time_zone_id
Expand Down Expand Up @@ -453,8 +453,8 @@ impl<A: AsCalendar> IsoTimeInput for DateTime<A> {
}

impl TimeZoneInput for CustomTimeZone {
fn gmt_offset(&self) -> Option<GmtOffset> {
self.gmt_offset
fn offset(&self) -> Option<UtcOffset> {
self.offset
}

fn time_zone_id(&self) -> Option<TimeZoneBcp47Id> {
Expand Down
36 changes: 18 additions & 18 deletions components/datetime/src/neo_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
//! ## Time Zone Formatting
//!
//! Here, we configure a [`NeoFormatter`] to format with generic non-location short,
//! which falls back to GMT when unavailable (see [`NeoTimeZoneGenericShortMarker`]).
//! which falls back to the offset when unavailable (see [`NeoTimeZoneGenericShortMarker`]).
//!
//! ```
//! use icu::calendar::DateTime;
Expand All @@ -267,7 +267,7 @@
//! use writeable::assert_try_writeable_eq;
//!
//! // Set up the time zone. Note: the inputs here are
//! // 1. The GMT offset
//! // 1. The offset
//! // 2. The IANA time zone ID
//! // 3. A datetime (for metazone resolution)
//! // 4. Note: we do not need the zone variant because of `load_generic_*()`
Expand Down Expand Up @@ -305,7 +305,7 @@
//! "HST"
//! );
//!
//! // GMT with offset - used when metazone is not available
//! // Raw offset - used when metazone is not available
//! let mut time_zone = "+0530".parse::<CustomTimeZone>().unwrap();
//! assert_try_writeable_eq!(
//! tzf.format(&time_zone),
Expand Down Expand Up @@ -2135,7 +2135,7 @@ impl_date_marker!(
impl_zone_marker!(
NeoTimeZoneSpecificMarker,
NeoTimeZoneSkeleton::specific(),
description = "specific time zone with inherited length, or GMT offset if unavailable",
description = "specific time zone with inherited length, or raw offset if unavailable",
sample_length = Medium,
sample = "CDT",
zone_essentials = yes,
Expand All @@ -2147,7 +2147,7 @@ impl_zone_marker!(
);

impl_zone_marker!(
/// When a display name is unavailable, falls back to the GMT offset format:
/// When a display name is unavailable, falls back to the offset format:
///
/// ```
/// use icu::calendar::{Date, Time};
Expand Down Expand Up @@ -2181,7 +2181,7 @@ impl_zone_marker!(
/// ```
NeoTimeZoneSpecificShortMarker,
NeoTimeZoneSkeleton::specific_short(),
description = "specific time zone with a shorter length, or GMT offset if unavailable",
description = "specific time zone with a shorter length, or raw offset if unavailable",
sample_length = no,
sample = "CDT",
zone_essentials = yes,
Expand All @@ -2195,7 +2195,7 @@ impl_zone_marker!(
impl_zone_marker!(
NeoTimeZoneSpecificLongMarker,
NeoTimeZoneSkeleton::specific_long(),
description = "specific time zone with a longer length, or GMT offset if unavailable",
description = "specific time zone with a longer length, or raw offset if unavailable",
sample_length = no,
sample = "Central Daylight Time",
zone_essentials = yes,
Expand All @@ -2207,11 +2207,11 @@ impl_zone_marker!(
);

impl_zone_marker!(
NeoTimeZoneGmtMarker,
NeoTimeZoneSkeleton::gmt(),
description = "GMT offset with inherited length",
NeoTimeZoneOffsetMarker,
NeoTimeZoneSkeleton::offset(),
description = "UTC offset with inherited length",
sample_length = Medium,
sample = "GMT-05:00", // TODO: Implement short localized GMT
sample = "GMT-05:00", // TODO: Implement short localized offset
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
Expand All @@ -2221,11 +2221,11 @@ impl_zone_marker!(
);

impl_zone_marker!(
NeoTimeZoneGmtShortMarker,
NeoTimeZoneSkeleton::gmt_short(),
description = "GMT offset with a shorter length",
NeoTimeZoneOffsetShortMarker,
NeoTimeZoneSkeleton::offset_short(),
description = "UTC offset with a shorter length",
sample_length = no,
sample = "GMT-05:00", // TODO: Implement short localized GMT
sample = "GMT-05:00", // TODO: Implement short localized offset
zone_essentials = yes,
zone_exemplar_cities = no,
zone_generic_long = no,
Expand All @@ -2235,9 +2235,9 @@ impl_zone_marker!(
);

impl_zone_marker!(
NeoTimeZoneGmtLongMarker,
NeoTimeZoneSkeleton::gmt_long(),
description = "GMT offset with a longer length",
NeoTimeZoneOffsetLongMarker,
NeoTimeZoneSkeleton::offset_long(),
description = "UTC offset with a longer length",
sample_length = no,
sample = "GMT-05:00",
zone_essentials = yes,
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/neo_skeleton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ pub enum NeoTimeZoneStyle {
///
/// When unavailable, falls back to [`NeoTimeZoneStyle::Offset`].
SpecificNonLocation,
/// The offset from UTC format, e.g., “GMT−8”.
/// The offset format, e.g., “GMT−8”.
Offset,
}

Expand Down
Loading

0 comments on commit d529cbc

Please sign in to comment.