Skip to main content

Module time

Module time 

Source
Expand description

The workspace’s clock.

Every crate in the workspace reads the time through this module and never through std::time::Instant or std::time::SystemTime directly. On every target but one, this module is std::time and nothing else: the types are the standard library’s own, so a value crosses any API that names std::time unchanged.

The exception is wasm32-unknown-unknown, the browser target. There the standard library compiles Instant::now() and SystemTime::now() and makes both panic when called, because the target defines no host clock. A green build therefore says nothing; the first tick of the engine aborts the module. On that target this module re-exports web-time, which reads performance.now() and Date.now() and has the same API.

clocks_are_read_through_core_time_only in this crate walks every crate’s sources and refuses a direct std::time clock import, because nothing else notices one until it runs in a browser.

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.