[][src]Struct libtzfile::Tz

pub struct Tz {
    pub tzh_timecnt_data: Vec<i64>,
    pub tzh_timecnt_indices: Vec<u8>,
    pub tzh_typecnt: Vec<Ttinfo>,
    pub tz_abbr: Vec<String>,
    // some fields omitted
}

This is the crate's primary structure, which contains the splitted TZfile fields and optional (via features) methods.

Fields

tzh_timecnt_data: Vec<i64>

transition times timestamps table

tzh_timecnt_indices: Vec<u8>

indices for the next field

tzh_typecnt: Vec<Ttinfo>

a struct containing UTC offset, daylight saving time, abbreviation index

tz_abbr: Vec<String>

abbreviations table

Implementations

impl Tz[src]

pub fn new(tz: &str) -> Result<Tz, TzError>[src]

Creates a Tz struct from a timezone file.

use libtzfile::Tz;
let tz = Tz::new(tzfile).unwrap();
 Tz { tzh_timecnt_data: [-2717643600, -1633273200, -1615132800, -1601823600, -1583683200, -880210800, -820519140, -812653140, -796845540, -84380400, -68659200], tzh_timecnt_indices: [2, 1, 2, 1, 2, 3, 2, 3, 2, 1, 2], tzh_typecnt: [Ttinfo { tt_gmtoff: -26898, tt_isdst: 0, tt_abbrind: 0 }, Ttinfo { tt_gmtoff: -21600, tt_isdst: 1, tt_abbrind: 1 }, Ttinfo { tt_gmtoff: -25200, tt_isdst: 0, tt_abbrind: 2 }, Ttinfo { tt_gmtoff: -21600, tt_isdst: 1, tt_abbrind: 3 }], tz_abbr: ["LMT", "MDT", "MST", "MWT"] }

pub fn transition_times(
    &self,
    y: Option<i32>
) -> Result<Vec<TransitionTime>, TzError>
[src]

Returns year's transition times for a timezone. If year is Some(0), returns current year's transition times. If there's no transition time for selected year, returns the last occured transition time (zone's current parameters). If no year (None) is specified, returns all transition times recorded in the TZfile .

use libtzfile::Tz;
println!("{:?}", Tz::new(tzfile).unwrap().transition_times(Some(2020)).unwrap());
[TransitionTime { time: 2020-03-29T01:00:00Z, utc_offset: 7200, isdst: true, abbreviation: "CEST" }, TransitionTime { time: 2020-10-25T01:00:00Z, utc_offset: 3600, isdst: false, abbreviation: "CET" }]

pub fn zoneinfo(&self) -> Result<Tzinfo, TzError>[src]

Returns convenient data about a timezone for current date and time.

use libtzfile::Tz;
println!("{:?}", Tz::new(tzfile).unwrap().zoneinfo().unwrap());
Tzinfo { timezone: "Europe/Paris", utc_datetime: 2020-09-05T16:41:44.279502100Z, datetime: 2020-09-05T18:41:44.279502100+02:00, dst_from: Some(2020-03-29T01:00:00Z), dst_until: Some(2020-10-25T01:00:00Z), dst_period: true, raw_offset: 3600, dst_offset: 7200, utc_offset: +02:00, abbreviation: "CEST", week_number: 36 }

Trait Implementations

impl Debug for Tz[src]

Auto Trait Implementations

impl RefUnwindSafe for Tz

impl Send for Tz

impl Sync for Tz

impl Unpin for Tz

impl UnwindSafe for Tz

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.