A pure Rust reimplementation of libc functions localtime
, gmtime
and mktime
.
This crate allows to convert between an Unix timestamp and a calendar time exprimed in the proleptic gregorian calendar with a provided time zone.
Time zones are provided to the library with a POSIX TZ
string which can be read from the environment.
Two formats are currently accepted for the TZ
string:
* std offset[dst[offset][,start[/time],end[/time]]]
providing a time zone description
* file
or :file
providing the path to a TZif file, which is absolute or relative to the system timezone directory.
Documentation is hosted on docs.rs.
This crate is mainly intended for UNIX platforms.
Since the time zone database files are not included in this crate, non UNIX users can download a copy of the database on the IANA site and compile the time zone database files to a local directory.
The database files can then be read by specifying an absolute path in the TZ
string:
rust
TimeZone::from_posix_tz(format!("{}/usr/share/zoneinfo/Pacific/Auckland", local_database_dir))?;
Note that the determination of the local time zone is not supported on non UNIX platforms.
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in time by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.