An absolute point in time, more efficient and precise than the float
-based Time,
but representing a narrower range of times.
This module represents absolute times with nanosecond precision, approximately between the years 1823 and 2116 CE.
You should normally default to using Time
instead of this module! The reasons are:
Time.t
values, so it will likely be
much more convenient for you.Time.t
and the other half expecting
Time_ns.t
.Time_ns
silently ignores overflow.Some reasons you might want want to actually prefer Time_ns.t
in certain cases:
int
s rather than float
s internally, which makes certain things easier to
reason about, since int
s respect a bunch of arithmetic identities that float
s
don't, e.g., x + (y + z) = (x + y) + z
.All in all, it would have been nice to have chosen Time_ns.t
to begin with, but
we're unlikely to flip everything to Time_ns.t
in the short term (see comment at the
end of time_ns.ml
).
See Core_kernel.Time_ns for additional low level documentation.
Unix epoch (1970-01-01 00:00:00 UTC)
Will raise on 32-bit platforms. Consider to_int63_ns_since_epoch
instead.
pause span
sleeps for span
time.
pause_forever
sleeps indefinitely.