Skip to content

Date & Time

Tulpar’s date/time API is intentionally small. There is no separate datetime module — these functions are built directly into the runtime.

FunctionReturnsUse it for
timestamp()int — seconds since 1970-01-01 UTCStoring in a database, age comparisons
time_ms()int — milliseconds since 1970-01-01 UTCHigher-resolution wall-clock time
now_iso8601()str"2026-05-02T14:33:09Z"Logging, JSON payloads, HTTP headers
Wall clock

For performance measurements, use clock_ms(). It is monotonic — it never goes backwards, even if the system clock is adjusted (NTP, daylight saving, manual change). Subtract two readings to get a duration in milliseconds.

Time a block

sleep(ms) blocks the current thread for at least the requested number of milliseconds. There is no sub-millisecond sleep.

Sleep

sleep is not a synchronization primitive — see the Concurrency page for proper inter-thread coordination.

NeedUse
”When did this happen?” (logged, persisted, sent over the wire)now_iso8601() or timestamp()
”How long did this take?”Two clock_ms() calls, subtract
”Pause for a bit”sleep(ms)
”Schedule something for later”sleep in a worker thread, or setTimeout from lib/async.tpr