libtz-sys
Rust FFI interface for IANA's libtz.
This provides an equivalent of glibc's localtime_r() function (and related
functions). The difference is that this library has been compiled such that the
getenv("TZ") call uses Rust's std::env::var_os() which protects it from
std::env::set_var() races which could otherwise cause segfaults.
Aside from that it should be a drop in replacement for glibc. It will read the tzdata files that the system has installed to calculate things like leap seconds and daylight saving time.
Usage
Add this to your Cargo.toml:
[]
= "0.2.0"
Example
use ;
use MaybeUninit;
use ;
let tzname = new.unwrap;
let tz = unsafe ;
if tz == null_mut
let time: TimeT = 127810800;
let mut tm = uninit;
let ret = unsafe ;
if ret == null_mut
let tm = unsafe ;
let zone: &str = unsafe ;
assert_eq!;
assert_eq!;
let time_again = unsafe ; // Round trip
if time_again == -1 else
unsafe ;
# Ok
License
The Rust code is distributed under the MIT license.
The libtz code is mostly public domain with a couple files using the BSD-3 clause license.
See LICENSE.md for details.