Up

Module Span

Signature

type t = private float
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
module Parts : sig .. end
include Core_kernel.Std.Comparable_binable with type t := t
include Comparable_intf.S_common
include Comparable_intf.Polymorphic_compare
include Polymorphic_compare_intf.Infix
type 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 equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int

ascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~cmp:ascending and List.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.

val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t

clamp_exn t ~min ~max returns t', the closest value to t such that between t' ~low:min ~high:max is true.

Raises if not (min <= max).

val clamp : t -> min:t -> max:t -> t Or_error.t
include Comparator.S with type t := t
type t
type comparator_witness
include Comparable_intf.Validate with type t := t
type t
val validate_lbound : min:t Maybe_bound.t -> t Validate.check
val validate_ubound : max:t Maybe_bound.t -> t Validate.check
val validate_bound : min:t Maybe_bound.t -> max:t Maybe_bound.t -> t Validate.check
include Comparable_intf.Map_and_set_binable with type t := t with type comparator_witness := comparator_witness
type t
include Comparator.S with type t := t
type t
type comparator_witness
include Core_kernel.Std.Comparable.With_zero with type t := t
type t
val validate_positive : t Core_kernel.Validate.check
val validate_non_negative : t Core_kernel.Validate.check
val validate_negative : t Core_kernel.Validate.check
val validate_non_positive : t Core_kernel.Validate.check
val is_positive : t -> bool
val is_non_negative : t -> bool
val is_negative : t -> bool
val is_non_positive : t -> bool
include Core_kernel.Std.Floatable with type t := t
type t
val of_float : float -> t
val to_float : t -> float
include Core_kernel.Std.Hashable_binable with type t := t
type t
val hash : t -> int
module Table : Hashable.Hashtbl.S_binable with type key = t
include Core_kernel.Std.Pretty_printer.S with type t := t
type t
val pp : Format.formatter -> t -> unit
include Core_kernel.Std.Robustly_comparable with type t := t
type 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 robustly_compare : t -> t -> int
val to_string : t -> string
val of_string : string -> t
val nanosecond : t
val microsecond : t
val millisecond : t
val second : t
val minute : t
val hour : t
val day : t
val robust_comparison_tolerance : t
val zero : t
val create : ?sign:Core_kernel.Std.Float.Sign.t -> ?day:int -> ?hr:int -> ?min:int -> ?sec:int -> ?ms:int -> ?us:int -> unit -> t
val to_parts : t -> Parts.t
val of_ns : float -> t
val of_us : float -> t
val of_ms : float -> t
val of_sec : float -> t
val of_int_sec : int -> t
val of_min : float -> t
val of_hr : float -> t
val of_day : float -> t
val to_ns : t -> float
val to_us : t -> float
val to_ms : t -> float
val to_sec : t -> float
val to_min : t -> float
val to_hr : t -> float
val to_day : t -> float
val (+) : t -> t -> t
Basic operations on spans
val (-) : t -> t -> t
val abs : t -> t

absolute value

val neg : t -> t

absolute value

negation

val scale : t -> float -> t

negation

val (/) : t -> float -> t
val (//) : t -> t -> float
val to_short_string : t -> string

to_short_string t pretty-prints approximate time span using no more than five characters if the span is positive, and six if the span is negative. Examples

  • "4h" = 4 hours
  • "5m" = 5 minutes
  • "4s" = 4 seconds
  • "10ms" = 10 milliseconds

only the most significant denomination is shown.

module Unit_of_time : sig .. end
val to_unit_of_time : t -> Unit_of_time.t

to_unit_of_time t = Day if abs t >= day, Hour if abs t >= hour, and so on down to Microsecond if abs t >= microsecond, and Nanosecond otherwise.

val of_unit_of_time : Unit_of_time.t -> t

of_unit_of_time unit_of_time produces a t representing the corresponding span.

val to_string_hum : ?delimiter:char -> ?decimals:int -> ?align_decimal:bool -> ?unit_of_time:Unit_of_time.t -> t -> string

to_string_hum t ~delimiter ~decimals ~align_decimal ~unit_of_time formats t using the given unit of time, or the largest appropriate units if none is specified, among "d"=day, "h"=hour, "m"=minute, "s"=second, "ms"=millisecond, "us"=microsecond, or "ns"=nanosecond. The magnitude of the time span in the chosen unit is formatted by:

Float.to_string_hum ~delimiter ~decimals ~strip_zero:(not align_decimal)

If align_decimal is true, the single-character suffixes are padded with an extra space character. In combination with not stripping zeroes, this means that the decimal point will occur a fixed number of characters from the end of the string.

val randomize : t -> percent:float -> t

randomize t ~percent returns a span +/- percent * original span. Percent must be between 0 and 1, and must be positive.

module Stable : sig .. end