timestamps

Types

A timestamp in milliseconds.

To create a new timestamp use timestamp.new().

pub opaque type Timestamp

Functions

pub fn add_hours(
  to_this timestamp: Timestamp,
  no_of hours: Int,
) -> Timestamp

Returns a timestamp that is hours hours after the given timestamp.

Example:

let ts = from_millis(1731431350344)
let ts_plus_2_hours = add_hours(ts, 2)
// -> 1731438550344
pub fn from_millis(milliseconds millis: Int) -> Timestamp

Creates a timestamp from given milliseconds.

Example:

let ts = from_millis(1731431350344)
// -> 1731431350344
pub fn is_after(
  timestamp1 t1: Timestamp,
  timestamp2 t2: Timestamp,
) -> Bool

Checks if the first timestamp is before the second timestamp.

Example:

let ts1 = from_millis(1731431350344)
let ts2 = from_millis(1731431350345)
is_before(ts1, ts2) // -> True
pub fn is_future(timestamp t: Timestamp) -> Bool

Checks if the given timestamp is in the future.

Example:

let ts = from_millis(2031431350344)
is_future(ts) // -> True
pub fn new() -> Timestamp

Returns the current time as a timestamp in milliseconds.

Example:

let ts = new()
// -> 1731431350344
pub fn to_string(timestamp t: Timestamp) -> String

Returns the value of the timestamp as a string.

pub fn value_of(timestamp t: Timestamp) -> Int

Returns the value of the timestamp.

Search Document