Skip to main content

LocalizedOffsetShort

Struct LocalizedOffsetShort 

Source
pub struct LocalizedOffsetShort;
Expand description

“GMT-5” ⇒ UTC offset, short length

§Examples

use icu::datetime::input::{Date, DateTime, Time, TimeZone, TimeZoneInfo, UtcOffset};
use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::LocalizedOffsetShort;
use icu::locale::locale;
use writeable::assert_writeable_eq;

let fmt = NoCalendarFormatter::try_new(
    locale!("en").into(),
    LocalizedOffsetShort
)
.unwrap();

// Time zone info for America/Chicago in the summer
let zone = TimeZone::from_iana_id("America/Chicago")
    .with_offset(UtcOffset::try_from_seconds(-5 * 3600).ok())
    .with_zone_name_timestamp(icu::time::zone::ZoneNameTimestamp::from_epoch_seconds(1661724000));

assert_writeable_eq!(
    fmt.format(&zone),
    "GMT-5"
);

All shapes of time zones can be formatted with this style.

use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::LocalizedOffsetShort;
use icu::datetime::input::Date;
use icu::datetime::input::{DateTime, Time, TimeZone, UtcOffset};
use icu::locale::locale;
use writeable::assert_writeable_eq;

let utc_offset = UtcOffset::try_from_seconds(-6 * 3600).unwrap();
let time_zone_basic =
    TimeZone::from_iana_id("America/Chicago").with_offset(Some(utc_offset));

let time_zone_at_time = time_zone_basic.with_zone_name_timestamp(
    icu::time::zone::ZoneNameTimestamp::from_epoch_seconds(1729202400),
);

let formatter = NoCalendarFormatter::try_new(
    locale!("en-US").into(),
    LocalizedOffsetShort,
)
.unwrap();

assert_writeable_eq!(formatter.format(&utc_offset), "GMT-6");

assert_writeable_eq!(formatter.format(&time_zone_basic), "GMT-6");

assert_writeable_eq!(formatter.format(&time_zone_at_time), "GMT-6");

Trait Implementations§

Source§

impl Clone for LocalizedOffsetShort

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LocalizedOffsetShort

Source§

impl DateTimeMarkers for LocalizedOffsetShort

Source§

type D = ()

Associated types for date formatting. Read more
Source§

type T = ()

Associated types for time formatting. Read more
Source§

type Z = LocalizedOffsetShort

Associated types for time zone formatting. Read more
Source§

type GluePatternV1 = NeverMarker<GluePattern<'static>>

Marker for loading the date/time glue pattern.
Source§

impl DateTimeNamesMarker for LocalizedOffsetShort

Source§

impl Debug for LocalizedOffsetShort

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LocalizedOffsetShort

Source§

impl GetField<CompositeFieldSet> for LocalizedOffsetShort

Source§

fn get_field(&self) -> CompositeFieldSet

Returns the value of this trait’s field T.
Source§

impl PartialEq for LocalizedOffsetShort

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LocalizedOffsetShort

Source§

impl UnstableSealed for LocalizedOffsetShort

Source§

impl ZoneMarkers for LocalizedOffsetShort

Source§

type TimeZoneIdInput = ()

Marker for resolving the time zone id input field.
Source§

type TimeZoneOffsetInput = Option<UtcOffset>

Marker for resolving the time zone offset input field.
Source§

type TimeZoneNameTimestampInput = ()

Marker for resolving the time zone non-location display names, which depend on the datetime.
Source§

type EssentialsV1 = TimezoneNamesEssentialsV1

Marker for loading core time zone data.
Source§

type LocationsV1 = NeverMarker<Locations<'static>>

Marker for loading location names for time zone formatting
Source§

type LocationsRootV1 = NeverMarker<Locations<'static>>

Marker for loading location names for time zone formatting
Source§

type ExemplarCitiesV1 = NeverMarker<ExemplarCities<'static>>

Marker for loading exemplar city names for time zone formatting
Source§

type ExemplarCitiesRootV1 = NeverMarker<ExemplarCities<'static>>

Marker for loading exemplar city names for time zone formatting
Source§

type GenericLongV1 = NeverMarker<MetazoneGenericNames<'static>>

Marker for loading generic long time zone names.
Source§

type GenericShortV1 = NeverMarker<MetazoneGenericNames<'static>>

Marker for loading generic short time zone names.
Source§

type StandardLongV1 = NeverMarker<MetazoneGenericNames<'static>>

Marker for loading standard long time zone names.
Source§

type SpecificLongV1 = NeverMarker<MetazoneSpecificNames<'static>>

Marker for loading specific long time zone names.
Source§

type SpecificShortV1 = NeverMarker<MetazoneSpecificNames<'static>>

Marker for loading generic short time zone names.
Source§

type MetazonePeriodV1 = NeverMarker<TimezonePeriods<'static>>

Marker for loading metazone periods.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T, R> AllInputMarkers<R> for T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<M, T> DateTimeNamesFrom<M> for T
where M: DateTimeNamesMarker, T: DateTimeNamesMarker, <<T as DateTimeNamesMarker>::YearNames as NamesContainer<ErasedMarker<YearNames<'static>>, YearNameLength>>::Container: From<<<M as DateTimeNamesMarker>::YearNames as NamesContainer<ErasedMarker<YearNames<'static>>, YearNameLength>>::Container>, <<T as DateTimeNamesMarker>::MonthNames as NamesContainer<ErasedMarker<MonthNames<'static>>, MonthNameLength>>::Container: From<<<M as DateTimeNamesMarker>::MonthNames as NamesContainer<ErasedMarker<MonthNames<'static>>, MonthNameLength>>::Container>, <<T as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container: From<<<M as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container>, <<T as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container: From<<<M as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container>, <<T as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container>, <<T as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container>, <<T as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container: From<<<M as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container>,

Source§

fn map_year_names( other: <<M as DateTimeNamesMarker>::YearNames as NamesContainer<ErasedMarker<YearNames<'static>>, YearNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::YearNames as NamesContainer<ErasedMarker<YearNames<'static>>, YearNameLength>>::Container

Source§

fn map_month_names( other: <<M as DateTimeNamesMarker>::MonthNames as NamesContainer<ErasedMarker<MonthNames<'static>>, MonthNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::MonthNames as NamesContainer<ErasedMarker<MonthNames<'static>>, MonthNameLength>>::Container

Source§

fn map_weekday_names( other: <<M as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container

Source§

fn map_day_period_names( other: <<M as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container

Source§

fn map_zone_essentials( other: <<M as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container

Source§

fn map_zone_locations( other: <<M as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container

Source§

fn map_zone_locations_root( other: <<M as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container

Source§

fn map_zone_exemplars( other: <<M as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container

Source§

fn map_zone_exemplars_root( other: <<M as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container

Source§

fn map_zone_generic_long( other: <<M as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container

Source§

fn map_zone_generic_short( other: <<M as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container

Source§

fn map_zone_standard_long( other: <<M as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container

Source§

fn map_zone_specific_long( other: <<M as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container

Source§

fn map_zone_specific_short( other: <<M as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container

Source§

fn map_metazone_lookup( other: <<M as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> GetField<T> for T
where T: Copy + UnstableSealed,

Source§

fn get_field(&self) -> T

Returns the value of this trait’s field T.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.