Skip to main content

Zone

Struct Zone 

Source
pub struct Zone<'a> { /* private fields */ }
Expand description

A parsed IANA timezone with all raw data exposed.

Zone borrows the TZif bytes it was parsed from; it is cheap to copy.

Implementations§

Source§

impl<'a> Zone<'a>

Source

pub fn name(&self) -> &'a str

The IANA timezone name.

Source

pub fn version(&self) -> u8

The TZif format version (1, 2, 3, or 4).

Source

pub fn raw_data(&self) -> &'a [u8]

The original TZif binary data this zone was parsed from.

Source

pub fn extend(&self) -> Option<&PosixTz<'a>>

The parsed POSIX TZ rule for computing future transitions, if any.

Source

pub fn extend_raw(&self) -> &'a str

The raw POSIX TZ footer string (empty if none).

Source

pub fn type_count(&self) -> usize

The number of local time types.

Source

pub fn type_at(&self, i: usize) -> ZoneType<'a>

Returns the i-th local time type. Panics if i >= type_count().

Source

pub fn types(&self) -> impl Iterator<Item = ZoneType<'a>> + 'a

Iterates over the zone’s local time types.

Source

pub fn transitions(&self) -> impl Iterator<Item = Transition> + 'a

Iterates over the stored transition records.

Source

pub fn leap_seconds(&self) -> impl Iterator<Item = LeapSecond> + 'a

Iterates over the leap-second records.

Source

pub fn lookup(&self, unix: i64) -> ZoneType<'a>

Returns the zone type in effect at the given Unix timestamp.

Searches stored transitions and falls back to the POSIX TZ rule for times after the last transition.

Source

pub fn transitions_for_range( &self, start_unix: i64, end_unix: i64, ) -> RangeIter<'a>

Returns transitions in the half-open interval [start_unix, end_unix), combining stored transitions with ones generated from the POSIX TZ extend rule. The result is yielded in chronological order.

Source§

impl Zone<'_>

Source

pub fn meta(&self) -> Option<ZoneMeta<'static>>

Returns metadata (countries, coordinates) for this timezone, or None.

Trait Implementations§

Source§

impl<'a> Clone for Zone<'a>

Source§

fn clone(&self) -> Zone<'a>

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<'a> Copy for Zone<'a>

Source§

impl<'a> Debug for Zone<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Zone<'a>

§

impl<'a> RefUnwindSafe for Zone<'a>

§

impl<'a> Send for Zone<'a>

§

impl<'a> Sync for Zone<'a>

§

impl<'a> Unpin for Zone<'a>

§

impl<'a> UnsafeUnpin for Zone<'a>

§

impl<'a> UnwindSafe for Zone<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

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.