From daa78474cfe4b196c918ac029146a55c4f9540b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Sat, 30 Dec 2023 13:21:02 +0100 Subject: [PATCH] Fix no-std --- CHANGELOG.md | 4 ++++ Cargo.toml | 4 ++-- README.md | 6 +----- src/lib.rs | 39 ++++++++++++++++++++++++++++++++------- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bf3983..743f19b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changes between the versions +### 0.4.14 (2023-12-30) + +* Fix no-std implementation + ### 0.4.13 (2023-12-27) * Update to [Time Zone Database 2023d](https://mm.icann.org/pipermail/tz-announce/2023-March/000080.html) diff --git a/Cargo.toml b/Cargo.toml index f604577..523ee2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tzdb" -version = "0.4.13" +version = "0.4.14" edition = "2021" authors = ["René Kijewski "] repository = "https://github.com/Kijewski/tzdb" @@ -13,7 +13,7 @@ rust-version = "1.60" [dependencies] tz-rs = { version = "^0.6.14", default-features = false, features = ["const"] } -tzdb_06 = { package = "tzdb", version = "0.6.0" } +tzdb_data = "0.1.0" # optional dependencies iana-time-zone = { version = "^0.1.46", default-features = false, optional = true } diff --git a/README.md b/README.md index cb26d10..c18b335 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,7 @@ 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), -currently in the version 2023d (released 2023-12-27). - -See the documentation for a full list the the contained time zones: - +This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones). ## Usage examples diff --git a/src/lib.rs b/src/lib.rs index e13476b..00f94ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,11 +42,7 @@ //! //! 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), -//! currently in the version 2023d (released 2023-12-27). -//! -//! See the documentation for a full list the the contained time zones: -//! +//! This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones). //! //! ## Usage examples //! @@ -102,9 +98,38 @@ mod test_by_name; #[cfg(feature = "local")] use iana_time_zone::get_timezone; - #[cfg_attr(docsrs, doc(no_inline))] -pub use tzdb_06::{raw_tz_by_name, time_zone, tz_by_name, TZ_NAMES, VERSION, VERSION_HASH}; +pub use tzdb_data::{time_zone, TZ_NAMES, VERSION, VERSION_HASH}; + +/// Find a time zone by name, e.g. `"Europe/Berlin"` (case-insensitive) +/// +/// # Example +/// +/// ``` +/// assert_eq!( +/// tzdb::time_zone::europe::BERLIN, +/// tzdb::tz_by_name("Europe/Berlin").unwrap(), +/// ); +/// ``` +#[inline] +pub fn tz_by_name>(s: S) -> Option> { + Some(*tzdb_data::find_tz(s.as_ref())?) +} + +/// Find the raw, unparsed time zone data by name, e.g. `"Europe/Berlin"` (case-insensitive) +/// +/// # Example +/// +/// ``` +/// assert_eq!( +/// tzdb::time_zone::europe::RAW_BERLIN, +/// tzdb::raw_tz_by_name("Europe/Berlin").unwrap(), +/// ); +/// ``` +#[inline] +pub fn raw_tz_by_name>(s: S) -> Option<&'static [u8]> { + tzdb_data::find_raw(s.as_ref()) +} /// Find the time zone of the current system ///