Warning. POSIX time does not increase monotonically, it is subject to operating system calendar time adjustements and can even go back in time. Use Mtime if you want to wait for wall-clock time spans.
Note. This is a minimal version of the ptime library which has more tools to deal with POSIX timestamp (e.g. date-time values) with the same representation, head there for more.
The type for picosecond precision POSIX timestamps in the range [min_stamp;max_stamp]. Note that POSIX timestamps, and hence values of this type are by definition always on the UTC timeline.
Waiting
Warning. This relies on an Unix.unblocker being setup on the executing domain.
wait_until t waits until the POSIX clock can be caught being greater or equal to the timestamp t. The actual supported resolution is unspecified and may also depend on scheduling but POSIX millisecond precision should be supported. Use observe_wait_until to measure the overshoot.
wait_until' t tag is the action for wait_until. The action invocation enables and synchronizes with tag when the POSIX clock can be caught to be greater or equal to the timestamp t.
is_later t ~than is true if and only if compare t than = 1.
Arithmetic
WARNING. A POSIX time span is not equal to an SI second based time span. Do not use these functions to perform calendar arithmetic or measure wall-clock durations, you will fail.
add_span t d is timestamp t + d, that is t with the signed POSIX span d added. None is returned if the result is not in the range [min_stamp;max_stamp].
sub_span t d is the timestamp t - d, that is t with the signed POSIX span d subtracted. None is returned if the result is not in the range [min_stamp;max_stamp].
of_float_s d is like of_span but with d as a floating point second POSIX span d. This function is compatible with the result of Unix.gettimeofday. Decimal fractional seconds beyond 1e-12 are truncated.