Sha256: 10aa33caa86645a16e2126fe1a86dda2b57f63caa9addcd726245fbc9657dc1b

Contents?: true

Size: 602 Bytes

Versions: 19

Compression:

Stored size: 602 Bytes

Contents

use js_sys::{Array, Intl, Object, Reflect};
use wasm_bindgen::JsValue;

pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
    let intl = Intl::DateTimeFormat::new(&Array::new(), &Object::new()).resolved_options();
    Reflect::get(&intl, &JsValue::from_str("timeZone"))
        .ok()
        .and_then(|tz| tz.as_string())
        .ok_or(crate::GetTimezoneError::OsError)
}

#[cfg(test)]
mod tests {
    use wasm_bindgen_test::*;

    #[wasm_bindgen_test]
    fn pass() {
        let tz = super::get_timezone_inner().unwrap();
        console_log!("tz={:?}", tz);
    }
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_wasm32_unknown.rs
wasmtime-28.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_wasm32_unknown.rs
wasmtime-27.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_wasm32_unknown.rs
wasmtime-26.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_wasm32_unknown.rs
wasmtime-25.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_wasm32.rs
wasmtime-25.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_wasm32.rs
wasmtime-25.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_wasm32.rs
wasmtime-24.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_wasm32.rs
wasmtime-23.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-22.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-21.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-20.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-20.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-18.0.3 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-17.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-17.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-16.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-15.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs
wasmtime-15.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_wasm32.rs