pub trait Clock {
// Required methods
fn now(&self) -> JsInstant;
fn system_time_millis(&self) -> i64;
}Expand description
Implement a clock that can be used to measure time.
Required Methods§
Sourcefn now(&self) -> JsInstant
fn now(&self) -> JsInstant
Returns the current monotonic time.
Implementers must ensure this is monotonic and should be used for measuring durations and scheduling timeouts. The engine assumes monotonicity.
Sourcefn system_time_millis(&self) -> i64
fn system_time_millis(&self) -> i64
Returns the current wall-clock time in milliseconds since the Unix epoch.
This is NOT monotonic and can go backward if the system clock is adjusted.
It should only be used for Date objects and other wall-clock time needs.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".