Timedesc.Span
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_s_ns : t -> int64 * int
Yields pair (s, ns)
where
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
.
ns
is always >= 0
and < 1_000_000_000
.
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
.
val get_s : t -> int64
Yields signed second of span, same as fst (to_s_ns _)
val get_ns_offset : t -> int
Yields the unsigned nanosecond offset, same as snd (to_s_ns _)
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 : Stdlib.Format.formatter -> t -> unit
module For_human : sig ... end