#[repr(transparent)]pub struct TimeZone(pub Subtag);Expand description
A CLDR time zone identity.
The primary definition of this type is in the icu_time crate. Other ICU4X crates re-export it for convenience.
This can be created directly from BCP-47 strings, or it can be parsed from IANA IDs.
CLDR uses difference equivalence classes than IANA. For example, Europe/Oslo is
an alias to Europe/Berlin in IANA (because they agree since 1970), but these are
different identities in CLDR, as we want to be able to say “Norway Time” and
“Germany Time”. On the other hand Europe/Belfast and Europe/London are the same
CLDR identity (“UK Time”).
See the docs on zone for more information.
use icu::locale::subtags::subtag;
use icu::time::zone::{IanaParser, TimeZone};
let parser = IanaParser::new();
assert_eq!(parser.parse("Europe/Oslo"), TimeZone(subtag!("noosl")));
assert_eq!(parser.parse("Europe/Berlin"), TimeZone(subtag!("deber")));
assert_eq!(parser.parse("Europe/Belfast"), TimeZone(subtag!("gblon")));
assert_eq!(parser.parse("Europe/London"), TimeZone(subtag!("gblon")));Tuple Fields§
§0: SubtagImplementations§
Source§impl TimeZone
 
impl TimeZone
Sourcepub const UNKNOWN: TimeZone
 
pub const UNKNOWN: TimeZone
The synthetic Etc/Unknown time zone.
This is the result of parsing unknown zones. It’s important that such parsing does not fail, as new zones are added all the time, and ICU4X might not be up to date.
Sourcepub const fn is_unknown(self) -> bool
 
pub const fn is_unknown(self) -> bool
Whether this TimeZone equals TimeZone::UNKNOWN.
Source§impl TimeZone
 
impl TimeZone
Sourcepub const fn with_offset(self, offset: Option<UtcOffset>) -> TimeZoneInfo<Base>
 
pub const fn with_offset(self, offset: Option<UtcOffset>) -> TimeZoneInfo<Base>
Associates this TimeZone with a UTC offset, returning a TimeZoneInfo.
Sourcepub const fn without_offset(self) -> TimeZoneInfo<Base>
 
pub const fn without_offset(self) -> TimeZoneInfo<Base>
Converts this TimeZone into a TimeZoneInfo without an offset.
Methods from Deref<Target = Subtag>§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TimeZone
 
impl<'de> Deserialize<'de> for TimeZone
Source§fn deserialize<__D>(
    __deserializer: __D,
) -> Result<TimeZone, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(
    __deserializer: __D,
) -> Result<TimeZone, <__D as Deserializer<'de>>::Error>where
    __D: Deserializer<'de>,
Source§impl<O> GetField<TimeZone> for TimeZoneInfo<O>where
    O: TimeZoneModel,
 
impl<O> GetField<TimeZone> for TimeZoneInfo<O>where
    O: TimeZoneModel,
Source§impl<C, A, Z> GetField<TimeZone> for ZonedDateTime<A, Z>
 
impl<C, A, Z> GetField<TimeZone> for ZonedDateTime<A, Z>
Source§impl IntoOption<TimeZone> for TimeZone
 
impl IntoOption<TimeZone> for TimeZone
Source§fn into_option(self) -> Option<TimeZone>
 
fn into_option(self) -> Option<TimeZone>
self as an Option<T>Source§impl Ord for TimeZone
 
impl Ord for TimeZone
Source§impl PartialOrd for TimeZone
 
impl PartialOrd for TimeZone
Source§impl ULE for TimeZone
 
impl ULE for TimeZone
Source§fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
 
fn validate_bytes(bytes: &[u8]) -> Result<(), UleError>
&[u8]. Read moreSource§unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
 
unsafe fn slice_from_bytes_unchecked(bytes: &[u8]) -> &[Self]
&[u8], and return it as &[Self] with the same lifetime, assuming
that this byte slice has previously been run through Self::parse_bytes_to_slice() with
success. Read moreSource§impl<'a> Yokeable<'a> for TimeZone
 
impl<'a> Yokeable<'a> for TimeZone
Source§type Output = TimeZone
 
type Output = TimeZone
Self with the 'static replaced with 'a, i.e. Self<'a>Source§impl<'a> ZeroMapKV<'a> for TimeZone
 
impl<'a> ZeroMapKV<'a> for TimeZone
impl Copy for TimeZone
impl Eq for TimeZone
impl StructuralPartialEq for TimeZone
Auto Trait Implementations§
impl Freeze for TimeZone
impl RefUnwindSafe for TimeZone
impl Send for TimeZone
impl Sync for TimeZone
impl Unpin for TimeZone
impl UnwindSafe for TimeZone
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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
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>
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>
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