Struct TimeZone

#[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 }

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

impl TimeZone

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.

impl TimeZone

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

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

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

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

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.

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.

impl TimeZone

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

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

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

impl Clone for TimeZone

fn clone(&self) -> TimeZone

impl Debug for TimeZone

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

impl PartialEq for TimeZone

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

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

impl<T> Any for TimeZone where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for TimeZone where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for TimeZone where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for TimeZone where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for TimeZone

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for TimeZone where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for TimeZone where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for TimeZone where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for TimeZone where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>