package affect
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=b328f6696e60c489da8cc2e8fad0537ca6634a39fc0c5de5840d4f98561f110617ef79ba8285ee8427dd99908c6b3d39114973598cddc5ded91abcce3b91b9a6
doc/affect.unix/Affect_unix/Ptime/index.html
Module Affect_unix.PtimeSource
POSIX time.
This time is measured by sampling this clock.
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.
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.
observe_wait_until is like wait_until but returns the value of the POSIX clock when the function returns.
Actions
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.
POSIX spans
Timestamps
now () is the current value of the POSIX clock.
max_stamp is 9999-12-31 23:59:59.999999999999 UTC, the latest timestamp representable.
Predicates
equal t0 t1 is true if and only if t0 and t1 are the same timestamps.
compare t0 t1 is a total order on timestamps that is compatible with timeline order.
is_earlier 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.
diff t t' is the signed POSIX span t - t' that happens between the timestamps t and t'.
Conversions
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.
to_float_s t is like to_span but returns a floating point second POSIX span.
Warning. Due to floating point inaccuracies do not expect the function to round trip with of_float_s; especially near Ptime.min_stamp and Ptime.max_stamp.
pp formats an unspecified, approximative, representation of timestamp, it looks like RFC 3339 but it's not do not use for serializing.
The POSIX clock
- Platforms with a POSIX clock (includes Linux) use
clock_gettimewithCLOCK_REALTIME. - On Darwin
gettimeofdayis used. - On Windows
GetSystemTimeandGetTimeZoneInformationare used.