github ↗
docs menu

Module Time.Span

Spans.

#type t = span

The type for spans.

Constructors

#val ns : int -> span

ns n is n nanoseconds.

#val us : int -> span

us n is n microseconds.

Raises Invalid_argument if the span is out of range.

#val ms : int -> span

ms n is like us in milliseconds.

#val s : int -> span

s n is like us in seconds.

#val minutes : int -> span

minutes n is like us in minutes.

#val hours : int -> span

hours n is like us in hours.

#val days : int -> span

days n is like us in days of 86,400 seconds.

Converting

#val of_ns : int64 -> span

of_ns n is n nanoseconds.

#val of_us : int64 -> span option

of_us n is n microseconds, or None if the span is out of range.

#val of_ms : int64 -> span option

of_ms n is like of_us in milliseconds.

#val of_s : int64 -> span option

of_s n is like of_us in seconds.

#val to_ns : span -> int64

to_ns d is d in nanoseconds.

#val to_us : span -> int64

to_us d is d in whole microseconds, rounded toward negative infinity: to_us (ns (-1)) is -1L.

#val to_ms : span -> int64

to_ms d is like to_us in milliseconds.

#val to_s : span -> int64

to_s d is like to_us in seconds.

Predicates and formatting

#val equal : span -> span -> bool

equal d0 d1 is true iff d0 and d1 are the same span.

#val compare : span -> span -> int

compare d0 d1 orders spans from the most negative to the most positive. It is compatible with equal.

#val pp : Stdlib.Format.formatter -> span -> unit

pp ppf d formats d as a minus sign when it is negative, then each nonzero component in hours, minutes, seconds, milliseconds, microseconds and nanoseconds, largest first, suffixed h, m, s, ms, us and ns: 168h, 1h30m, 1s500ms, -250us. The zero span formats as 0s. A span never formats in days, which in printed steps are calendar days (pp_step).