Crate bity_ic_canister_time

Crate bity_ic_canister_time 

Source
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.