README

vectie/moonclaw/clock does not have a README file

#
Clock

pub(open) trait Clock {
fn now(self : Self) -> Timestamp
fn now_str(self : Self) -> String
}

#
Epoch

type Epoch

impl Clock for Epoch

#
Timestamp

type Timestamp derive(Eq)

Unix timestamp represented as milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC).
impl Show for Timestamp
impl ToJson for Timestamp

#
Timestamp::from_ms

fn Timestamp::from_ms(ms : Int64) -> Timestamp

Creates a new timestamp from the given number of milliseconds since the Unix epoch.

Parameters:

  • ms : The number of milliseconds since January 1, 1970, 00:00:00 UTC.

Returns a Timestamp representing the given time.

#
Timestamp::ms

fn Timestamp::ms(self : Timestamp) -> Int64

Gets the millisecond value of this timestamp.

Parameters:

  • self : The timestamp to extract the millisecond value from.

Returns the number of milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC) as an Int64.

#
Timestamp::ms_since

fn Timestamp::ms_since(self : Timestamp, other : Timestamp) -> Int64

Calculates the difference in milliseconds between this timestamp and another timestamp.

Parameters:

  • self : The timestamp to subtract from.
  • other : The timestamp to subtract.

Returns the difference in milliseconds as an Int64. A positive value indicates that self is later than other, while a negative value indicates that self is earlier than other.

#
Timestamp::truncate_to_s

fn Timestamp::truncate_to_s(self : Timestamp) -> Int64

Converts the timestamp from milliseconds to seconds by truncating the millisecond portion.

Parameters:

  • self : The timestamp in milliseconds to convert.

Returns the number of seconds since the Unix epoch as an Int64, with the millisecond portion truncated.

#
epoch

let epoch : Epoch