Skip to main content

Module time

Module time 

Expand description

The toolkit’s clock: tilo-clock, under the toolkit’s module path.

Every monotonic and wall-clock reading in ui goes through now and wall, and every clock type is named through this module rather than std::time. A host that has no process clock of its own (or one that must be virtualised, such as a deterministic replay) then has exactly one seam to provide, instead of a hundred scattered Instant::now() calls.

On targets with a native clock the re-exports are std::time’s own types, so values cross freely into crates that name std::time directly.

crates/sdk/ui-core/clippy.toml rejects Instant::now and SystemTime::now everywhere else in the crate.

Structs§

Duration
A Duration type to represent a span of time, typically used for system timeouts.
Instant
A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
SystemTimeError
An error returned from the duration_since and elapsed methods on SystemTime, used to learn how far in the opposite direction a system time lies.

Constants§

UNIX_EPOCH
An anchor in time which can be used to create new SystemTime instances or learn about where in time a SystemTime lies.

Functions§

from_file_time
A std::time wall-clock time, such as a file’s modification time, as this crate’s. The identity where the clock is native.
from_std
A std::time wall-clock time, such as a file’s modification time, as this crate’s. The identity where the clock is native.
is_synchronised
Whether this device’s clock is synchronised with a time source, when the platform can say: Some(true) synchronised, Some(false) known not to be, None when nothing here knows. A device whose clock is minutes out produces codes nothing accepts, and the machine is the only place that can tell.
local_zone_name
The IANA name of the local time zone, when the system names one: $TZ (without a leading :), else the zone /etc/localtime links to below zoneinfo/. None where the system names none, and on the web; local times still follow the system’s offsets there. Callers check the name against their zone database.
now
The current monotonic instant, for measuring elapsed time and scheduling deadlines.
pin_wall
Pin the wall clock to at for the rest of the process, so a screenshot capture shows the same date and time on every run. The monotonic clock (now) keeps running: animations and timeouts still advance. Never called in a live session.
to_std
A wall-clock time as std::time’s, for crates and APIs that name std::time::SystemTime directly. The identity where the clock is native.
try_unix_now
Whole seconds since the Unix epoch, or None if the clock precedes it.
try_unix_now_ms
Milliseconds since the Unix epoch, or None if the clock precedes it.
try_unix_now_ns
Nanoseconds since the Unix epoch, or None if the clock precedes it.
unix_now
Whole seconds since the Unix epoch; 0 if the clock precedes it.
unix_now_i64
Whole seconds since the Unix epoch as a signed timestamp; 0 if the clock precedes it.
unix_now_ms
Milliseconds since the Unix epoch; 0 if the clock precedes it.
unix_now_ms_i64
Milliseconds since the Unix epoch as a signed timestamp; 0 if the clock precedes it.
unix_now_ns
Nanoseconds since the Unix epoch; 0 if the clock precedes it.
wall
The current wall-clock time, for timestamps shown to people or persisted. Under a pin it is that instant, every time.
wall_frozen
Whether pin_wall pinned the wall clock.