Skip to content

time

The time module provides UTC date/time instants, signed durations, sleeping, and scoped timeouts.

Functions

sleep duration

Suspends the current strand.

Parameters

Name Type Description
duration Duration | Int | Float Sleep duration. Numeric values are interpreted as seconds.

Notes:

  • Duration must be non-negative.
  • Floating-point values must be finite.
sleep 0.25
sleep (DateTime.from_unix(10) - DateTime.from_unix(10))

timeout duration block

Runs block with a scoped timeout.

Parameters

Name Type Description
duration Duration | Int | Float Timeout duration. Numeric values are interpreted as seconds.
block Func Block to run under the timeout scope.

Returns

block result

Errors

Exception Condition
TimedOutError The timeout is observed at a suspend or interrupt-check point before the block completes
timeout 1 do
  sleep 10

Types