Sha256: 375ae951d1417f63e6d77c9add7f7f646f24c0054cb8407bd4b9f06907494888

Contents?: true

Size: 799 Bytes

Versions: 19

Compression:

Stored size: 799 Bytes

Contents

use std::fs::OpenOptions;
use std::io::{BufRead, BufReader};

pub(crate) fn get_timezone_inner() -> Result<String, crate::GetTimezoneError> {
    // https://illumos.org/man/5/TIMEZONE
    // https://docs.oracle.com/cd/E23824_01/html/821-1473/uc-timezone-4.html

    let file = OpenOptions::new().read(true).open("/etc/default/init")?;
    let mut reader = BufReader::with_capacity(1536, file);
    let mut line = String::with_capacity(80);
    loop {
        line.clear();
        let count = reader.read_line(&mut line)?;
        if count == 0 {
            return Err(crate::GetTimezoneError::FailedParsingString);
        } else if line.starts_with("TZ=") {
            line.truncate(line.trim_end().len());
            line.replace_range(..3, "");
            return Ok(line);
        }
    }
}

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