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>,
/* private fields */
}
Expand description
This is the crate’s primary structure, which contains the TZfile fields.
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§
source§impl Tz
impl Tz
sourcepub fn new(tz: &str) -> Result<Tz, TzError>
pub fn new(tz: &str) -> Result<Tz, TzError>
Creates a Tz struct from a TZ system file
use libtzfile::Tz;
let tzfile: &str = "/usr/share/zoneinfo/America/Phoenix";
println!("{:?}", 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_utoff: -26898, tt_isdst: 0, tt_abbrind: 0 }, Ttinfo { tt_utoff: -21600, tt_isdst: 1, tt_abbrind: 1 }, Ttinfo { tt_utoff: -25200, tt_isdst: 0, tt_abbrind: 2 }, Ttinfo { tt_utoff: -21600, tt_isdst: 1, tt_abbrind: 3 }], tz_abbr: ["LMT", "MDT", "MST", "MWT"] }
sourcepub fn transition_times(
&self,
y: Option<i32>
) -> Result<Vec<TransitionTime>, TzError>
pub fn transition_times( &self, y: Option<i32> ) -> Result<Vec<TransitionTime>, TzError>
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" }]
sourcepub fn zoneinfo(&self) -> Result<Tzinfo, TzError>
pub fn zoneinfo(&self) -> Result<Tzinfo, TzError>
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§
Auto Trait Implementations§
impl Freeze for Tz
impl RefUnwindSafe for Tz
impl Send for Tz
impl Sync for Tz
impl Unpin for Tz
impl UnwindSafe for Tz
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