package timere

  1. Overview
  2. Docs
type t = private {
  1. s : int64;
  2. ns : int;
}

Signed/directional span of time expressed as a tuple of (s, ns)

  • s is the signed second of the span
  • ns is the unsigned nanosecond offset

The 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)

val ns_count_in_s : int
val ns_count_in_s_float : float
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 add : t -> t -> t
val sub : t -> t -> t
val succ : t -> t
val pred : t -> t
val neg : t -> t
val abs : t -> t
val equal : t -> t -> bool
val lt : t -> t -> bool
val le : t -> t -> bool
val gt : t -> t -> bool
val ge : t -> t -> bool
val compare : t -> t -> int
val to_float : t -> float
val of_float : float -> t
val max : t -> t -> t
val min : t -> t -> t
val (<) : t -> t -> bool
val (<=) : t -> t -> bool
val (>) : t -> t -> bool
val (>=) : t -> t -> bool
val (=) : t -> t -> bool
val (<>) : t -> t -> bool
val (-) : t -> t -> t
val (+) : t -> t -> t
val to_string : t -> string
val pp : Stdlib.Format.formatter -> t -> unit
val to_sexp : t -> CCSexp.t
val to_sexp_string : t -> string
val of_sexp : CCSexp.t -> (t, string) Stdlib.result
val of_sexp_string : string -> (t, string) Stdlib.result
val pp_sexp : Stdlib.Format.formatter -> t -> unit
OCaml

Innovation. Community. Security.