#[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.
Sourcepub fn from_iana_id(iana_id: &str) -> TimeZone
pub fn from_iana_id(iana_id: &str) -> TimeZone
Construct a TimeZone from an IANA time zone ID.
See IanaParser.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn from_windows_id(windows_id: &str, region: Option<Region>) -> TimeZone
pub fn from_windows_id(windows_id: &str, region: Option<Region>) -> TimeZone
Construct a TimeZone from a Windows time zone ID and region.
See WindowsParser.
✨ Enabled with the compiled_data Cargo feature.
Sourcepub fn from_system_id(id: &str, _region: Option<Region>) -> TimeZone
pub fn from_system_id(id: &str, _region: Option<Region>) -> TimeZone
Construct a TimeZone from the platform-specific ID.
On Windows systems, this resolves to TimeZone::from_windows_id, on
all other systems to TimeZone::from_iana_id.
✨ Enabled with the compiled_data Cargo feature.
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§
impl Copy for TimeZone
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>,
impl Eq for TimeZone
Source§impl<C, A, Z> GetField<TimeZone> for ZonedDateTime<A, Z>
impl<C, A, Z> GetField<TimeZone> for ZonedDateTime<A, Z>
Source§impl<O> GetField<TimeZone> for TimeZoneInfo<O>where
O: TimeZoneModel,
impl<O> GetField<TimeZone> for TimeZoneInfo<O>where
O: TimeZoneModel,
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
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for TimeZone
impl PartialOrd for TimeZone
Source§impl Serialize for TimeZone
impl Serialize for TimeZone
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for TimeZone
Source§impl ULE for TimeZone
impl ULE for TimeZone
Source§fn validate_bytes(bytes_all: &[u8]) -> Result<(), UleError>
fn validate_bytes(bytes_all: &[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<'yoke> Yokeable<'yoke> for TimeZone
impl<'yoke> Yokeable<'yoke> for TimeZone
Source§type Output = TimeZone
type Output = TimeZone
Self with the 'static replaced with 'a, i.e. Self<'a>Auto Trait Implementations§
impl Freeze for TimeZone
impl RefUnwindSafe for TimeZone
impl Send for TimeZone
impl Sync for TimeZone
impl Unpin for TimeZone
impl UnsafeUnpin 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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