Date & Time
Tulpar’s date/time API is intentionally small. There is no separate
datetime module — these functions are built directly into the
runtime.
Time of day
Section titled “Time of day”| Function | Returns | Use it for |
|---|---|---|
timestamp() | int — seconds since 1970-01-01 UTC | Storing in a database, age comparisons |
time_ms() | int — milliseconds since 1970-01-01 UTC | Higher-resolution wall-clock time |
now_iso8601() | str — "2026-05-02T14:33:09Z" | Logging, JSON payloads, HTTP headers |
Wall clock
Çıktı
Measuring elapsed time
Section titled “Measuring elapsed time”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
Çıktı
Sleeping
Section titled “Sleeping”sleep(ms) blocks the current thread for at least the requested
number of milliseconds. There is no sub-millisecond sleep.
Sleep
Çıktı
sleep is not a synchronization primitive — see the
Concurrency page for proper inter-thread
coordination.
Choosing the right clock
Section titled “Choosing the right clock”| Need | Use |
|---|---|
| ”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 |