Skip to content

The q* stdlib docs

qtime: time operations

qtime provides the time.* built-ins for reading the wall clock and doing simple time arithmetic. Timestamps are modeled as 64-bit integers; time.now returns Unix seconds and time.now_ms returns Unix milliseconds. The underlying Value::Timestamp type is an i64 (nanosecond-capable) model, and these built-ins return plain Int values.

What it gives you#

FunctionArgumentsReturnsBehavior
time.nownoneIntCurrent Unix time in whole seconds.
time.now_msnoneIntCurrent Unix time in whole milliseconds.
time.add_secsa, bIntSum of the two integer arguments.

time.now and time.now_ms read the system clock relative to the Unix epoch; if the clock is somehow before the epoch the functions return 0. time.add_secs reads two positional integer arguments and returns their sum — a convenience for advancing a timestamp by a number of seconds. Each integer argument accepts an Int or a Timestamp value; anything else counts as 0.

The Timestamp model#

In the shared value model a Timestamp is an i64. The qtime built-ins return seconds (time.now) and milliseconds (time.now_ms) as Int values, which is what QQL consumes directly. The i64 width leaves ample range for nanosecond precision in the model itself.

Resource budget#

Each call reads a clock (or two integers) and emits one tiny result record — fixed, scalar work. Every time.* function declares a 256-byte memory budget and zero storage.

Example#

time.add_secs adds its two integer arguments — here advancing 1000 by 60 seconds.

Request

time.add_secs(1000, 60)

# wire form:
{ "0": {"Int": 1000}, "1": {"Int": 60} }

Response

{ "result": { "Int": 1060 } }

Output

1060

Request

time.now()

Response

{ "result": { "Int": 1750000000 } }

Output

a Unix-seconds integer (greater than 1,600,000,000 in practice)