Library
Module
Module type
Parameter
Class
Class type
Signed/directional span of time expressed as a tuple of (s, ns)
s
is the signed second of the spanns
is the unsigned nanosecond offsetThe actual span represented is defined as s * 10^9 + ns
in nanosecond, regardless of the sign of s
Order is defined using lexicographic order, i.e. lt x y iff. x.s < y.s || (x.s = y.s && x.ns < y.ns)
module For_human : sig ... end
val zero : t
val make : ?s:int64 -> ?ns:int -> unit -> t
s
defaults to 0L
, ns
defaults to 0
ns
may be negative, and is normalized during construction
Interpretation of provided input is still s + ns
, i.e. if you wish to represent "negative (1 second and 500 nanosecond)", then the call could look like make ~s:(-1L) ~ns:(-500)
val make_small : ?s:int -> ?ns:int -> unit -> t
Wrapper around make
val to_float_s : t -> float
Returns span in seconds, fraction represents subsecond span.
Representation is the same as result from Unix.gettimeofday
.
val of_float_s : float -> t
Convert from span in seconds, fraction represents subsecond span
Representation is the same as result from Unix.gettimeofday
.
Rounds to nearest second
For round x
x.ns >= 500_000_000
, then round x = ceil x
round x = floor x
val to_string : t -> string
val pp : Format.formatter -> t -> unit
val to_sexp_string : t -> string
val pp_sexp : Format.formatter -> t -> unit