diff --git a/Cargo.toml b/Cargo.toml index 639e57d25c..1f99d5f5de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,11 @@ edition = "2018" name = "chrono" [features] -default = ["clock", "std", "wasmbind"] +default = ["clock", "std", "wasmbind", "iana-time-zone"] alloc = [] libc = [] std = [] -clock = ["std", "windows-sys", "iana-time-zone"] +clock = ["std", "windows-sys"] wasmbind = ["wasm-bindgen", "js-sys"] unstable-locales = ["pure-rust-locales", "alloc"] __internal_bench = ["criterion"] diff --git a/src/offset/local/unix.rs b/src/offset/local/unix.rs index 22114f21ef..6d02069a44 100644 --- a/src/offset/local/unix.rs +++ b/src/offset/local/unix.rs @@ -78,12 +78,18 @@ const TZDB_LOCATION: &str = "/usr/share/lib/zoneinfo"; #[cfg(not(any(target_os = "android", target_os = "aix")))] const TZDB_LOCATION: &str = "/usr/share/zoneinfo"; +#[cfg(feature = "iana-time-zone")] fn fallback_timezone() -> Option { let tz_name = iana_time_zone::get_timezone().ok()?; let bytes = fs::read(format!("{}/{}", TZDB_LOCATION, tz_name)).ok()?; TimeZone::from_tz_data(&bytes).ok() } +#[cfg(not(feature = "iana-time-zone"))] +fn fallback_timezone() -> Option { + None +} + impl Default for Cache { fn default() -> Cache { // default to UTC if no local timezone can be found