Crate libtz

source ·
Expand description

libtz

Idiomatic Rust interface for IANA’s libtz (git repository) via libtz-sys.

Links: [Documentation] [Git Repository] [Crates.io]

Usage

Add this to your Cargo.toml:

[dependencies]
libtz = "0.1.1"

Example

use libtz::{Timezone, TimeT};
use std::time::{SystemTime, UNIX_EPOCH};

let tz = libtz::Timezone::default()?;
let tm = tz.localtime(SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() as TimeT)?;
println!("tm = {:?}", tm);

Status

This is young code and I’m not sure about the finaly interface yet. It may change rapidly.

License

Copyright © 2023 David Caldwell david@porkrind.org

MIT Licensed. See LICENSE.md for details.

Structs

A Timezone holds the storage for the libtz C library. Create one with Timezone::new (to specify a specific timezone) or Timezone::default (to use the default system timezone, which it looks for in /etc/localtime).
A broken down time representation, logically equivalent to struct tm in unix (though not binary compatible).

Functions

Convert system time to UTC Tm.
Convert UTC Tm to system time.

Type Definitions

System time. On unix, the number of seconds since 00:00:00 UTC on 1 January 1970.