pub enum TimeZone {
Iana(TimeZoneId),
FixedOffset(TimeZoneOffset),
}Expand description
A time zone represented by either an IANA-shaped identifier or a fixed offset.
Variants§
Iana(TimeZoneId)
An IANA-shaped time zone identifier.
FixedOffset(TimeZoneOffset)
A fixed UTC offset.
Implementations§
Source§impl TimeZone
impl TimeZone
Sourcepub fn try_new(input: &str) -> Result<Self, TimeZoneParseError>
pub fn try_new(input: &str) -> Result<Self, TimeZoneParseError>
Parses a time zone with diagnostic errors.
§Errors
Returns TimeZoneParseError when the input is empty, contains whitespace,
is an invalid fixed offset, or is not an IANA-shaped identifier.
Sourcepub const fn iana(identifier: TimeZoneId) -> Self
pub const fn iana(identifier: TimeZoneId) -> Self
Returns an IANA time zone value.
Sourcepub const fn fixed_offset(offset: TimeZoneOffset) -> Self
pub const fn fixed_offset(offset: TimeZoneOffset) -> Self
Returns a fixed-offset time zone value.
Sourcepub const fn as_time_zone_id(&self) -> Option<&TimeZoneId>
pub const fn as_time_zone_id(&self) -> Option<&TimeZoneId>
Returns the IANA identifier when this time zone is identifier-based.
Sourcepub const fn offset(&self) -> Option<TimeZoneOffset>
pub const fn offset(&self) -> Option<TimeZoneOffset>
Returns the fixed offset when this time zone is offset-based.
Sourcepub const fn is_iana(&self) -> bool
pub const fn is_iana(&self) -> bool
Returns true when this time zone is an IANA-shaped identifier.
Sourcepub const fn is_fixed_offset(&self) -> bool
pub const fn is_fixed_offset(&self) -> bool
Returns true when this time zone is a fixed offset.
Trait Implementations§
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,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for TimeZone
impl PartialOrd 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 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
Mutably borrows from an owned value. Read more