Skip to main content

TimeZone

Struct TimeZone 

Source
#[repr(align(8))]
pub struct TimeZone { pub version: u8, pub checksum: u32, pub designations: MaybeStaticSlice<Abbreviation>, pub posix_tz: Option<TimeZone>, pub types: MaybeStaticSlice<LocalTimeType>, pub transitions: Transitions, }
Expand description

A representation of an unnamed time zone backed by TZif data.

Two time zones are considered equivalent when their CRC32 sums are equivalent.

Fields§

§version: u8

An ASCII byte corresponding to the version number. So, 0x50 is ‘2’.

§checksum: u32

A CRC32 checksum of the underlying TZif data.

This, along with the time zone’s IANA identifier, is used to provide a “best effort” but also cheap notion of strict equality between two time zones.

§designations: MaybeStaticSlice<Abbreviation>

The time zone abbreviations referenced by local time types.

§posix_tz: Option<TimeZone>

A POSIX time zone used for determining time zone transitions after the last transition in some TZif data.

This is technically optional, but is usually present.

§types: MaybeStaticSlice<LocalTimeType>

The local time types in this TZif data.

Each local time type represents a distinct combination of offset, abbreviation and whether the region is in daylight saving time or not.

§transitions: Transitions

The concrete transitions that make up this time zone.

Implementations§

Source§

impl TimeZone

Source

pub fn parse(bytes: &[u8]) -> Result<TimeZone, ParseError>

Parses the given data as a TZif formatted file.

The name given is attached to the returned value, but is otherwise not significant.

In general, callers may assume that it is safe to pass arbitrary or even untrusted data to this function and count on it not panicking or using resources that are not limited to a small constant factor of the size of the data itself.

This is only available when the alloc feature is enabled because parsing TZif data requires heap allocation.

Source§

impl TimeZone

Source

pub fn to_offset(&self, timestamp: Timestamp) -> Offset

Returns the appropriate time zone offset to use for the given timestamp.

Source

pub fn to_offset_info(&self, timestamp: Timestamp) -> OffsetInfo

Returns the appropriate time zone offset to use for the given timestamp.

This also includes whether the offset returned should be considered to be DST or not, along with the time zone abbreviation (e.g., EST for standard time in New York, and EDT for DST in New York).

Source

pub fn to_ambiguous_timestamp(&self, dt: DateTime) -> AmbiguousTimestamp

Returns a possibly ambiguous timestamp for the given civil datetime.

The given datetime should correspond to the “wall” clock time of what humans use to tell time for this time zone.

Note that “ambiguous timestamp” is represented by the possible selection of offsets that could be applied to the given datetime. In general, it is only ambiguous around transitions to-and-from DST. The ambiguity can arise as a “fold” (when a particular wall clock time is repeated) or as a “gap” (when a particular wall clock time is skipped entirely).

Source

pub fn previous_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>

Returns the timestamp of the most recent time zone transition prior to the timestamp given. If one doesn’t exist, None is returned.

Source

pub fn next_transition<'t>(&'t self, ts: Timestamp) -> Option<Transition>

Returns the timestamp of the soonest time zone transition after the timestamp given. If one doesn’t exist, None is returned.

Source§

impl TimeZone

Source

pub fn into_named(self, name: TimeZoneId) -> MaybeNamedTimeZone

Converts this unnamed time zone into a time zone with the given name.

Source

pub fn into_maybe_named(self, name: Option<TimeZoneId>) -> MaybeNamedTimeZone

Converts this unnamed time zone into a time zone with the given optional name.

Trait Implementations§

Source§

impl Clone for TimeZone

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 Debug for TimeZone

Source§

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

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

impl PartialEq for TimeZone

Source§

fn eq(&self, rhs: &TimeZone) -> bool

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.