Time & Clock Subpackage (time)
The time module provides high-precision clocks, UNIX epoch timestamps, thread sleeping, duration measurements, and date formatting.
API Reference
time.now(): String
Returns the current UTC timestamp formatted as an ISO-8601 / RFC-3339 string.
time.unix(): Int
Returns the current UNIX epoch timestamp in seconds.
time.unix_ms(): Int
Returns the current UNIX epoch timestamp in milliseconds.
time.sleep(ms: Int): Void
Pauses the current execution thread for the specified number of milliseconds.
time.elapsed(start_ts: Int): Int
Calculates the elapsed milliseconds between the current time and a starting timestamp from time.unix_ms().
const start = time.unix_ms()
// ... execute work ...
const duration = time.elapsed(start)
print("Work completed in {duration} ms")
time.format(ts: Int, fmt: String): String
Formats a UNIX epoch timestamp (in seconds) into a date and time string.