Skip to content

Commit

Permalink
Fix no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Dec 30, 2023
1 parent abed2e7 commit daa7847
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tzdb"
version = "0.4.13"
version = "0.4.14"
edition = "2021"
authors = ["René Kijewski <[email protected]>"]
repository = "https://github.com/Kijewski/tzdb"
Expand All @@ -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 }
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
<https://docs.rs/tzdb/latest/tzdb/time_zone/index.html>
This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones).

## Usage examples

Expand Down
39 changes: 32 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//! <https://docs.rs/tzdb/latest/tzdb/time_zone/index.html>
//! This crate provides all time zones found in the [Time Zone Database](https://www.iana.org/time-zones).
//!
//! ## Usage examples
//!
Expand Down Expand Up @@ -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: AsRef<[u8]>>(s: S) -> Option<tz::TimeZoneRef<'static>> {
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: AsRef<[u8]>>(s: S) -> Option<&'static [u8]> {
tzdb_data::find_raw(s.as_ref())
}

/// Find the time zone of the current system
///
Expand Down

0 comments on commit daa7847

Please sign in to comment.