Skip to main content

timezone

Function timezone 

Source
pub fn timezone() -> Result<TimeZone>
Expand description

The time zone: the zone name and the current offset, not zone arithmetic (that is a calendar crate’s job). TZ is used only when it is a valid name; it is never opened as a path (T4). When /etc/localtime is a copy rather than a link, the name comes from /etc/timezone or is None: zone files are not compared to guess (E-92).

The time zone is an identifying value: keep it out of output that leaves the machine unless that is intended.

let tz = sys_lib::host::timezone()?;
println!("zone {:?}, offset {} s", tz.iana, tz.utc_offset_seconds);

§Errors

Os when the offset cannot be read.