Instant

An Instant represents a unique point in time, stored as a signed 128-bit integer in nanoseconds. It represents the amount of time that has passed since 1st January 1970 at 00:00:00 (the Unix epoch), without any timezone or calendar systems. By default, its initial value is taken from the system clock.

let now be new Instant

It may be instantiated using an amount in nanoseconds.

let some_instant be new Instant with just 100_000_000

Operators

The Instant and Duration classes overload many operators for convenience. See the list below for details.

Instant  [= != > < >= <=] Instant  → Boolean
Duration [= != > < >= <=] Duration → Boolean
Instant  [+-] Duration → Instant
Instant  [-]  Instant  → Duration
Duration [+-] Duration → Duration
Duration [*/] Float    → Duration
Duration [*/] Integer  → Duration
Duration [/]  Duration → Float
Duration [%]  Duration → Duration
[-]Duration → Duration

Constructor

Creates a new Instant by parsing the given nanoseconds.

let a be new Instant with just 10_000_000
print do a's to_string # 10000000

Methods

Returns the unix timestamp in nanoseconds as a string.

let a be new Instant with just 10_000_000
print do a's to_string # 10000000

Returns the unix timestamp in nanoseconds as a number in JSON format.

Returns the unix timestamp in nanoseconds.

let a be new Instant with just 10_000_000
print do a's to_nanoseconds # 10000000

Errors:

  • If the nanoseconds exceed what an Integer could hold.

Returns the unix timestamp in milliseconds.

let a be new Instant with just 10_000_000
print do a's to_milliseconds # 10

Errors:

  • If the nanoseconds exceed what an Integer could hold.
print "hello world"