pub struct Tzinfo {
pub timezone: String,
pub utc_datetime: DateTime<Utc>,
pub datetime: DateTime<FixedOffset>,
pub dst_from: Option<DateTime<Utc>>,
pub dst_until: Option<DateTime<Utc>>,
pub dst_period: bool,
pub raw_offset: isize,
pub dst_offset: isize,
pub utc_offset: FixedOffset,
pub abbreviation: String,
pub week_number: i32,
}
Expand description
Convenient and human-readable informations about a timezone (available with the parse or json features). With the json feature enabled, the Tzinfo struct implements the Serialize trait.
Some explanations about the offset fields:
- raw_offset : the “normal” offset to utc, in seconds
- dst_offset : the offset to utc during daylight saving time, in seconds
- utc_offset : the current offset to utc, taking into account daylight saving time or not (according to dst_from and dst_until), in +/- HH:MM
Fields§
§timezone: String
Timezone name
utc_datetime: DateTime<Utc>
UTC time
datetime: DateTime<FixedOffset>
Local time
dst_from: Option<DateTime<Utc>>
Start of DST period
dst_until: Option<DateTime<Utc>>
End of DST period
dst_period: bool
Are we in DST period ?
raw_offset: isize
Normal offset to UTC, in seconds
dst_offset: isize
DST offset to UTC, in seconds
utc_offset: FixedOffset
current offset to UTC, in +/-HH:MM
abbreviation: String
Timezone abbreviation
week_number: i32
Week number
Implementations§
source§impl Tzinfo
impl Tzinfo
sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Transforms the Tzinfo struct to a JSON string
use libtzfile::{Tz, TzError};
let tz = Tz::new(tzfile)?
.zoneinfo()?
.to_json()?;
println!("{}", tz);
{"timezone":"Europe/Paris","utc_datetime":"2020-09-05T18:04:50.546668500Z","datetime":"2020-09-05T20:04:50.546668500+02:00","dst_from":"2020-03-29T01:00:00Z","dst_until":"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 Tzinfo
impl RefUnwindSafe for Tzinfo
impl Send for Tzinfo
impl Sync for Tzinfo
impl Unpin for Tzinfo
impl UnwindSafe for Tzinfo
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