pub struct GenericShort;Expand description
“CT” ⇒ time zone in generic non-location format, short length
§Examples
use icu::datetime::input::{Date, DateTime, Time, TimeZone, TimeZoneInfo, UtcOffset};
use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::GenericShort;
use icu::locale::{locale, subtags::subtag};
use writeable::assert_writeable_eq;
let fmt = NoCalendarFormatter::try_new(
locale!("en").into(),
GenericShort
)
.unwrap();
// Time zone info for America/Chicago in the summer
let zone = TimeZone(subtag!("uschi"))
.with_offset("-05".parse().ok())
.at_date_time_iso(DateTime{ date: Date::try_new_iso(2022, 8, 29).unwrap(), time: Time::start_of_day() });
assert_writeable_eq!(
fmt.format(&zone),
"CT"
);If a non-location name is not defined, falls back to the location format, which is often significantly longer! This is the case for most zones, as each locale only contains the short names that are used locally and generally understood:
use icu::datetime::input::{Date, DateTime, Time, TimeZone, TimeZoneInfo, UtcOffset};
use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::GenericShort;
use icu::locale::{locale, subtags::subtag};
use writeable::assert_writeable_eq;
// Time zone info for Asia/Tokyo
let zone = TimeZone(subtag!("jptyo"))
.with_offset("+09".parse().ok())
.at_date_time_iso(DateTime{ date: Date::try_new_iso(2022, 1, 29).unwrap(), time: Time::start_of_day() });
let fmt = NoCalendarFormatter::try_new(
locale!("en").into(),
GenericShort,
)
.unwrap();
// "JST" is not generally known in American English
assert_writeable_eq!(
fmt.format(&zone),
"Japan Time"
);If the offset doesn’t match one of the valid offsets for the zone, falls back to the localized offset format:
use icu::datetime::input::{Date, DateTime, Time, TimeZone, TimeZoneInfo, UtcOffset};
use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::GenericShort;
use icu::locale::{locale, subtags::subtag};
use writeable::assert_writeable_eq;
// Time zone info for America/Chicago with a wrong offset
let wrong_offset = TimeZone(subtag!("uschi"))
.with_offset("-04".parse().ok())
.at_date_time_iso(DateTime{ date: Date::try_new_iso(2022, 8, 29).unwrap(), time: Time::start_of_day() });
let fmt = NoCalendarFormatter::try_new(
locale!("en").into(),
GenericShort,
)
.unwrap();
assert_writeable_eq!(
fmt.format(&wrong_offset),
"GMT-4"
);
// This of course always happens for the unknown time zone
let unk = TimeZone::UNKNOWN.with_offset(wrong_offset.offset()).with_zone_name_timestamp(wrong_offset.zone_name_timestamp());
assert_writeable_eq!(
fmt.format(&unk),
"GMT-4"
);Since non-location names might change over time, this time zone style requires a reference time.
ⓘ
use icu::datetime::NoCalendarFormatter;
use icu::datetime::fieldsets::zone::GenericShort;
use icu::datetime::input::TimeZone;
use icu::locale::{locale, subtags::subtag};
let time_zone_basic = TimeZone(subtag!("uschi")).without_offset();
let formatter = NoCalendarFormatter::try_new(
locale!("en-US").into(),
GenericShort,
)
.unwrap();
// error[E0271]: type mismatch resolving `<Base as TimeZoneModel>::ZoneNameTimestamp == ZoneNameTimestamp`
formatter.format(&time_zone_basic);Trait Implementations§
Source§impl Clone for GenericShort
impl Clone for GenericShort
Source§fn clone(&self) -> GenericShort
fn clone(&self) -> GenericShort
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl DateTimeMarkers for GenericShort
impl DateTimeMarkers for GenericShort
Source§type Z = GenericShort
type Z = GenericShort
Associated types for time zone formatting. Read more
Source§type GluePatternV1 = NeverMarker<GluePattern<'static>>
type GluePatternV1 = NeverMarker<GluePattern<'static>>
Marker for loading the date/time glue pattern.
Source§impl DateTimeNamesMarker for GenericShort
impl DateTimeNamesMarker for GenericShort
type YearNames = ()
type MonthNames = ()
type WeekdayNames = ()
type DayPeriodNames = ()
type ZoneEssentials = TimezoneNamesEssentialsV1
type ZoneLocations = TimezoneNamesLocationsOverrideV1
type ZoneLocationsRoot = TimezoneNamesLocationsRootV1
type ZoneExemplars = ()
type ZoneExemplarsRoot = ()
type ZoneGenericLong = ()
type ZoneGenericShort = TimezoneNamesGenericShortV1
type ZoneStandardLong = ()
type ZoneSpecificLong = ()
type ZoneSpecificShort = ()
type MetazoneLookup = TimezonePeriodsV1
Source§impl Debug for GenericShort
impl Debug for GenericShort
Source§impl GetField<CompositeFieldSet> for GenericShort
impl GetField<CompositeFieldSet> for GenericShort
Source§fn get_field(&self) -> CompositeFieldSet
fn get_field(&self) -> CompositeFieldSet
Returns the value of this trait’s field
T.Source§impl PartialEq for GenericShort
impl PartialEq for GenericShort
Source§impl ZoneMarkers for GenericShort
impl ZoneMarkers for GenericShort
Source§type TimeZoneIdInput = TimeZone
type TimeZoneIdInput = TimeZone
Marker for resolving the time zone id input field.
Source§type TimeZoneOffsetInput = Option<UtcOffset>
type TimeZoneOffsetInput = Option<UtcOffset>
Marker for resolving the time zone offset input field.
Source§type TimeZoneNameTimestampInput = ZoneNameTimestamp
type TimeZoneNameTimestampInput = ZoneNameTimestamp
Marker for resolving the time zone non-location display names, which depend on the datetime.
Source§type EssentialsV1 = TimezoneNamesEssentialsV1
type EssentialsV1 = TimezoneNamesEssentialsV1
Marker for loading core time zone data.
Source§type LocationsV1 = TimezoneNamesLocationsOverrideV1
type LocationsV1 = TimezoneNamesLocationsOverrideV1
Marker for loading location names for time zone formatting
Source§type LocationsRootV1 = TimezoneNamesLocationsRootV1
type LocationsRootV1 = TimezoneNamesLocationsRootV1
Marker for loading location names for time zone formatting
Source§type ExemplarCitiesV1 = NeverMarker<ExemplarCities<'static>>
type ExemplarCitiesV1 = NeverMarker<ExemplarCities<'static>>
Marker for loading exemplar city names for time zone formatting
Source§type ExemplarCitiesRootV1 = NeverMarker<ExemplarCities<'static>>
type ExemplarCitiesRootV1 = NeverMarker<ExemplarCities<'static>>
Marker for loading exemplar city names for time zone formatting
Source§type GenericLongV1 = NeverMarker<MetazoneGenericNames<'static>>
type GenericLongV1 = NeverMarker<MetazoneGenericNames<'static>>
Marker for loading generic long time zone names.
Source§type GenericShortV1 = TimezoneNamesGenericShortV1
type GenericShortV1 = TimezoneNamesGenericShortV1
Marker for loading generic short time zone names.
Source§type StandardLongV1 = NeverMarker<MetazoneGenericNames<'static>>
type StandardLongV1 = NeverMarker<MetazoneGenericNames<'static>>
Marker for loading standard long time zone names.
Source§type SpecificLongV1 = NeverMarker<MetazoneSpecificNames<'static>>
type SpecificLongV1 = NeverMarker<MetazoneSpecificNames<'static>>
Marker for loading specific long time zone names.
Source§type SpecificShortV1 = NeverMarker<MetazoneSpecificNames<'static>>
type SpecificShortV1 = NeverMarker<MetazoneSpecificNames<'static>>
Marker for loading generic short time zone names.
Source§type MetazonePeriodV1 = TimezonePeriodsV1
type MetazonePeriodV1 = TimezonePeriodsV1
Marker for loading metazone periods.
impl Copy for GenericShort
impl Eq for GenericShort
impl StructuralPartialEq for GenericShort
impl UnstableSealed for GenericShort
Auto Trait Implementations§
impl Freeze for GenericShort
impl RefUnwindSafe for GenericShort
impl Send for GenericShort
impl Sync for GenericShort
impl Unpin for GenericShort
impl UnwindSafe for GenericShort
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<M, T> DateTimeNamesFrom<M> for Twhere
M: DateTimeNamesMarker,
T: DateTimeNamesMarker,
<<T as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: From<<<M as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container>,
<<T as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: From<<<M as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, 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>,
impl<M, T> DateTimeNamesFrom<M> for Twhere
M: DateTimeNamesMarker,
T: DateTimeNamesMarker,
<<T as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container: From<<<M as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container>,
<<T as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container: From<<<M as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, 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>,
fn map_year_names( other: <<M as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::YearNames as NamesContainer<YearNamesV1, YearNameLength>>::Container
fn map_month_names( other: <<M as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::MonthNames as NamesContainer<MonthNamesV1, MonthNameLength>>::Container
fn map_weekday_names( other: <<M as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::WeekdayNames as NamesContainer<DatetimeNamesWeekdayV1, WeekdayNameLength>>::Container
fn map_day_period_names( other: <<M as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container, ) -> <<T as DateTimeNamesMarker>::DayPeriodNames as NamesContainer<DatetimeNamesDayperiodV1, DayPeriodNameLength>>::Container
fn map_zone_essentials( other: <<M as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneEssentials as NamesContainer<TimezoneNamesEssentialsV1, ()>>::Container
fn map_zone_locations( other: <<M as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneLocations as NamesContainer<TimezoneNamesLocationsOverrideV1, ()>>::Container
fn map_zone_locations_root( other: <<M as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneLocationsRoot as NamesContainer<TimezoneNamesLocationsRootV1, ()>>::Container
fn map_zone_exemplars( other: <<M as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneExemplars as NamesContainer<TimezoneNamesCitiesOverrideV1, ()>>::Container
fn map_zone_exemplars_root( other: <<M as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneExemplarsRoot as NamesContainer<TimezoneNamesCitiesRootV1, ()>>::Container
fn map_zone_generic_long( other: <<M as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneGenericLong as NamesContainer<TimezoneNamesGenericLongV1, ()>>::Container
fn map_zone_generic_short( other: <<M as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneGenericShort as NamesContainer<TimezoneNamesGenericShortV1, ()>>::Container
fn map_zone_standard_long( other: <<M as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneStandardLong as NamesContainer<TimezoneNamesStandardLongV1, ()>>::Container
fn map_zone_specific_long( other: <<M as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneSpecificLong as NamesContainer<TimezoneNamesSpecificLongV1, ()>>::Container
fn map_zone_specific_short( other: <<M as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::ZoneSpecificShort as NamesContainer<TimezoneNamesSpecificShortV1, ()>>::Container
fn map_metazone_lookup( other: <<M as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container, ) -> <<T as DateTimeNamesMarker>::MetazoneLookup as NamesContainer<TimezonePeriodsV1, ()>>::Container
Source§impl<T> GetField<T> for Twhere
T: Copy + UnstableSealed,
impl<T> GetField<T> for Twhere
T: Copy + UnstableSealed,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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