set fallback feature in iana-time-zone depedency

This commit is contained in:
Eric Sheppard 2022-08-10 22:51:43 +10:00 committed by Dirkjan Ochtman
parent 511d368990
commit 84f98e01c7
2 changed files with 1 additions and 8 deletions

View File

@ -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", optional = true }
js-sys = { version = "0.3", optional = true } # 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 }

View File

@ -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()?;