Crate local_clock

source ·
Expand description

An instance-local, reprogrammable, real time clock.

This crate’s primary export is the LocalClock trait, which defines an interface for interacting with instances of reprogrammable real time clocks, decoupled from any particular platform’s global real time clock.

Also included in local_time is SystemTimeClock, which is a basic in-tree implementation of LocalClock backed by std::time::SystemTime. Unless you’re worried about handling instances where SystemTime jumps backwards, this is perfectly reasonable implementation to use.

This crate deliberately takes a minimalist approach to dependencies, and avoids pulling in any “heavyweight” date/time crates by default (e.g: time, chrono, etc…). That said, native integration with some of these crates is provided via optional features.

§Features

  • inspect - Derives the Inspect trait on various types.
  • time_exts - Integration with the [time] crate
    • Provides From/Into implementations to interop with duration and date/time types from time.
    • Changes the Debug implementation of LocalClockTime to print a human readable date (instead of a raw duration since the Unix Epoch).

Structs§

Traits§