https://github.com/kijewski/tzdb
Static time zone information for tz-rs.
https://github.com/kijewski/tzdb
iana-tzdb rust timezone tz tzdata
Last synced: about 1 year ago
JSON representation
Static time zone information for tz-rs.
- Host: GitHub
- URL: https://github.com/kijewski/tzdb
- Owner: Kijewski
- License: apache-2.0
- Created: 2022-02-21T12:08:33.000Z (about 4 years ago)
- Default Branch: v0.7.x
- Last Pushed: 2024-09-30T08:41:38.000Z (over 1 year ago)
- Last Synced: 2024-10-14T14:10:36.681Z (over 1 year ago)
- Topics: iana-tzdb, rust, timezone, tz, tzdata
- Language: Rust
- Homepage: https://docs.rs/tzdb
- Size: 1.48 MB
- Stars: 42
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# tzdb — Time Zone Database
[](https://github.com/Kijewski/tzdb/actions/workflows/ci.yml)
[](https://crates.io/crates/tzdb)
[](https://docs.rs/tzdb/)

[](https://github.com/Kijewski/tzdb/blob/v0.6.1/LICENSE.md "License: Apache-2.0")
Static time zone information for [tz-rs](https://crates.io/crates/tz-rs).
This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones).
## Usage examples
```rust
let time_zone = tzdb::local_tz()?; // tz::TimeZoneRef<'_>
let current_time = tzdb::now::local()?; // tz::DateTime
// access by identifier
let time_zone = tzdb::time_zone::europe::KYIV;
let current_time = tzdb::now::in_tz(tzdb::time_zone::europe::KYIV)?;
// access by name
let time_zone = tzdb::tz_by_name("Europe/Berlin")?;
let current_time = tzdb::now::in_named("Europe/Berlin")?;
// names are case insensitive
let time_zone = tzdb::tz_by_name("ArCtIc/LongYeArByEn")?;
let current_time = tzdb::now::in_named("ArCtIc/LoNgYeArByEn")?;
// provide a default time zone
let current_time = tzdb::now::local_or(tzdb::time_zone::GMT)?;
let current_time = tzdb::now::in_named_or(tzdb::time_zone::GMT, "Some/City")?;
```
## Feature flags
* `local` (enabled by default) — enable functions to query the current system time
* `now` (enabled by default) — enable functions to query the current system time
* `std` (enabled by default, `now` and `local`) — enable the use of features in the `std` crate
* `alloc` (enabled by `std`) — enable the use of features in the `alloc` crate