Sha256: 0be21eb1831d1b2bc780a22a0d7e88255ecf356a26e113d2bb4fb1412e705f24

Contents?: true

Size: 1004 Bytes

Versions: 8

Compression:

Stored size: 1004 Bytes

Contents

use ambient_authority::AmbientAuthority;
use iana_time_zone::get_timezone;

/// A reference to a timezone resource.
pub struct Timezone(());

/// An error type returned by `Timezone::timezone_name`.
#[derive(Debug)]
pub struct TimezoneError(String);

impl std::error::Error for TimezoneError {}

impl std::fmt::Display for TimezoneError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        self.0.fmt(f)
    }
}

impl Timezone {
    /// Constructs a new instance of `Self`.
    ///
    /// # Ambient Authority
    ///
    /// This uses ambient authority to accesses clocks.
    #[inline]
    pub const fn new(ambient_authority: AmbientAuthority) -> Self {
        let _ = ambient_authority;
        Self(())
    }

    /// Returns the combined date and time with timezone.
    ///
    /// Converts NaiveTime to DateTime
    #[inline]
    pub fn timezone_name(&self) -> Result<String, TimezoneError> {
        get_timezone().map_err(|e| TimezoneError(e.to_string()))
    }
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/cap-time-ext-3.4.2/src/timezone.rs
wasmtime-28.0.0 ./ext/cargo-vendor/cap-time-ext-3.4.2/src/timezone.rs
wasmtime-27.0.0 ./ext/cargo-vendor/cap-time-ext-3.4.1/src/timezone.rs
wasmtime-26.0.0 ./ext/cargo-vendor/cap-time-ext-3.3.0/src/timezone.rs
wasmtime-25.0.2 ./ext/cargo-vendor/cap-time-ext-3.2.0/src/timezone.rs
wasmtime-25.0.1 ./ext/cargo-vendor/cap-time-ext-3.2.0/src/timezone.rs
wasmtime-25.0.0 ./ext/cargo-vendor/cap-time-ext-3.2.0/src/timezone.rs
wasmtime-24.0.0 ./ext/cargo-vendor/cap-time-ext-3.2.0/src/timezone.rs