Expand description
Module for time-related operations in Internet Computer canisters.
This module provides utilities for working with time in canisters, including timestamp functions, time constants, and timer scheduling functions. It supports both WASM and non-WASM environments.
§Example
use icrc7_nft::libraries::canister_time::{timestamp_millis, run_interval};
use std::time::Duration;
let current_time = timestamp_millis();
run_interval(Duration::from_secs(60), || {
println!("Running periodic task");
});Constants§
- DAY_
IN_ MS - Number of milliseconds in one day
- DAY_
IN_ SECONDS - Number of seconds in one day
- HOUR_
IN_ MS - Number of milliseconds in one hour
- MINUTE_
IN_ MS - Number of milliseconds in one minute
- NANOS_
PER_ MILLISECOND - Number of nanoseconds in one millisecond
- SECOND_
IN_ MS - Number of milliseconds in one second
- WEEK_
IN_ MS - Number of milliseconds in one week
Functions§
- now_
millis - Returns the current time in milliseconds.
- now_
nanos - Returns the current time in nanoseconds (non-WASM implementation).
- run_
interval - Runs a function at the specified interval.
- run_
now_ then_ interval - Runs a function immediately and then at the specified interval.
- run_
once - Runs a function once immediately.
- start_
job_ daily_ at - start_
job_ weekly_ at - timestamp_
micros - Returns the current timestamp in microseconds.
- timestamp_
millis - Returns the current timestamp in milliseconds.
- timestamp_
nanos - Returns the current timestamp in nanoseconds (non-WASM implementation).
- timestamp_
seconds - Returns the current timestamp in seconds.