Sha256: 3da37f1b87f87a0ed215734f2b373b2d187bcf49386adfe8bfff207f9a5e8fe2

Contents?: true

Size: 936 Bytes

Versions: 19

Compression:

Stored size: 936 Bytes

Contents

use std::sync::Once;

use android_system_properties::AndroidSystemProperties;

use crate::ffi_utils::android_timezone_property_name;

pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
    let key = android_timezone_property_name();

    get_properties()
        .and_then(|properties| properties.get_from_cstr(key))
        .ok_or(crate::GetTimezoneError::OsError)
}

fn get_properties() -> Option<&'static AndroidSystemProperties> {
    static INITIALIZED: Once = Once::new();
    static mut PROPERTIES: Option<AndroidSystemProperties> = None;

    INITIALIZED.call_once(|| {
        let properties = AndroidSystemProperties::new();
        // SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once.
        unsafe { PROPERTIES = Some(properties) };
    });

    // SAFETY: `INITIALIZED` is synchronizing. The variable is only assigned to once.
    unsafe { PROPERTIES.as_ref() }
}

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_android.rs
wasmtime-28.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_android.rs
wasmtime-27.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_android.rs
wasmtime-26.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.61/src/tz_android.rs
wasmtime-25.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_android.rs
wasmtime-25.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_android.rs
wasmtime-25.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_android.rs
wasmtime-24.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.60/src/tz_android.rs
wasmtime-23.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-22.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-21.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-20.0.2 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-20.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-18.0.3 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-17.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-17.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-16.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-15.0.1 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs
wasmtime-15.0.0 ./ext/cargo-vendor/iana-time-zone-0.1.59/src/tz_android.rs