Skip to content

Commit

Permalink
set fallback feature in iana-time-zone depedency
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-crypto committed Aug 10, 2022
2 parents 24715f0 + 6f9af6f commit 31b3184
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Expand Up @@ -40,13 +40,12 @@ serde = { version = "1.0.99", default-features = false, optional = true }
pure-rust-locales = { version = "0.5.2", optional = true }
criterion = { version = "0.3", optional = true }
rkyv = {version = "0.7", optional = true}
iana-time-zone = { version = "0.1.41", optional = true, features = ["fallback"] }

[target.'cfg(all(target_arch = "wasm32", not(any(target_os = "emscripten", target_os = "wasi"))))'.dependencies]
wasm-bindgen = { version = "0.2" }
js-sys = { version = "0.3" } # contains FFI bindings for the JS Date API

[target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "solaris", target_env = "sgx")))'.dependencies]
iana-time-zone = { version = "0.1.41", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3.0", features = ["std", "minwinbase", "minwindef", "timezoneapi"], optional = true }
Expand Down
6 changes: 0 additions & 6 deletions src/offset/local/unix.rs
Expand Up @@ -103,12 +103,6 @@ const TZDB_LOCATION: &str = " /system/usr/share/zoneinfo";
#[cfg(not(target_os = "android"))]
const TZDB_LOCATION: &str = "/usr/share/zoneinfo";

#[cfg(any(target_os = "emscripten", target_os = "wasi", target_os = "solaris"))]
fn fallback_timezone() -> Option<TimeZone> {
Some(TimeZone::utc())
}

#[cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "solaris")))]
fn fallback_timezone() -> Option<TimeZone> {
let tz_name = iana_time_zone::get_timezone().ok()?;
let bytes = fs::read(format!("{}/{}", TZDB_LOCATION, tz_name)).ok()?;
Expand Down

0 comments on commit 31b3184

Please sign in to comment.