Skip to main content

Clock

Trait Clock 

Source
pub trait Clock:
    Send
    + Sync
    + 'static {
    // Required method
    fn now(&self) -> Timestamp;

    // Provided methods
    fn now_in(&self, tz: &TimeZone) -> Zoned { ... }
    fn today_in(&self, tz: &TimeZone) -> Date { ... }
    fn now_unix_millis(&self) -> i64 { ... }
}
Expand description

Wall-clock readouts. Single port for “what time is it?” across all surfaces.

now() is the only required method; the zone-aware readouts derive from it via jiff (tzdb available on every arm, including wasm via the bundled db).

Required Methods§

Source

fn now(&self) -> Timestamp

Provided Methods§

Source

fn now_in(&self, tz: &TimeZone) -> Zoned

Source

fn today_in(&self, tz: &TimeZone) -> Date

Source

fn now_unix_millis(&self) -> i64

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§