Time_ns.Spantype t = private Int63.tt is immediate on 64bit boxes and so plays nicely with the GC write barrier.
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_valuetype underlying = Int63.tSpan.t represents a span of time (e.g. 7 minutes, 3 hours, 12.8 days). The span may be positive or negative.
include Bin_prot.Binable.S with type t := tinclude Bin_prot.Binable.S_only_functions with type t := tval bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.tval hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_valueinclude Ppx_sexp_conv_lib.Sexpable.S with type t := tval t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.tmodule Parts : sig ... endinclude Comparable.S_binable with type t := tinclude Base.Comparable.S with type t := tinclude Base.Comparisons.S with type t := tcompare t1 t2 returns 0 if t1 is equal to t2, a negative integer if t1 is less than t2, and a positive integer if t1 is greater than t2.
ascending is identical to compare. descending x y = ascending y x. These are intended to be mnemonic when used like List.sort ~compare:ascending and List.sort
~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
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 Base.Or_error.tinclude Base.Comparator.S with type t := tval validate_lbound : min:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.checkval validate_bound : min:t Base.Maybe_bound.t -> max:t Base.Maybe_bound.t -> t Base.Validate.checkmodule Replace_polymorphic_compare : Base.Comparable.Polymorphic_compare with type t := tinclude Comparator.S with type t := t with type comparator_witness := comparator_witnessval comparator : (t, comparator_witness) Comparator.comparatormodule Map : Map.S_binable with type Key.t = t with type Key.comparator_witness = comparator_witnessmodule Set : Set.S_binable with type Elt.t = t with type Elt.comparator_witness = comparator_witnessinclude Comparable.With_zero with type t := tval validate_positive : t Base.Validate.checkval validate_non_negative : t Base.Validate.checkval validate_negative : t Base.Validate.checkval validate_non_positive : t Base.Validate.checkval is_positive : t -> boolval is_non_negative : t -> boolval is_negative : t -> boolval is_non_positive : t -> boolval sign : t -> Base__Sign0.tReturns Neg, Zero, or Pos in a way consistent with the above functions.
include Hashable.S_binable with type t := tval hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_valueval hashable : t Hashtbl.Hashable.tmodule Table : Hashtbl.S_binable with type key = tmodule Hash_set : Hash_set.S_binable with type elt = tmodule Hash_queue : Hash_queue.S with type key = tinclude Base.Pretty_printer.S with type t := tval pp : Base.Formatter.t -> t -> unitinclude Quickcheck.S_range with type t := tinclude Quickcheck_intf.S with type t := tval quickcheck_generator : t Base_quickcheck.Generator.tval quickcheck_observer : t Base_quickcheck.Observer.tval quickcheck_shrinker : t Base_quickcheck.Shrinker.tval gen_incl : t -> t -> t Base_quickcheck.Generator.tgen_incl lower_bound upper_bound produces values between lower_bound and upper_bound, inclusive. It uses an ad hoc distribution that stresses boundary conditions more often than a uniform distribution, while still able to produce any value in the range. Raises if lower_bound > upper_bound.
val gen_uniform_incl : t -> t -> t Base_quickcheck.Generator.tgen_uniform_incl lower_bound upper_bound produces a generator for values uniformly distributed between lower_bound and upper_bound, inclusive. Raises if lower_bound > upper_bound.
val to_string : t -> Base.String.tTime spans are denominated as a float suffixed by a unit of time; the valid suffixes are listed below:
d - days h - hours m - minutes s - seconds ms - milliseconds us - microseconds ns - nanoseconds
to_string and sexp_of_t use a mixed-unit format, which breaks the input span into parts and concatenates them in descending order of unit size. For example, pi days is rendered as "3d3h23m53.60527015815s". If the span is negative, a single "-" precedes the entire string. For extremely large (>10^15 days) or small (<1us) spans, a unit may be repeated to ensure the string conversion round-trips.
of_string and t_of_sexp accept any combination of (nonnegative float string)(unit of time suffix) in any order, without spaces, and sums up the durations of each of the parts for the magnitude of the span. The input may be prefixed by "-" for negative spans.
String and sexp conversions round-trip precisely, that is:
Span.of_string (Span.to_string t) = t val of_string : Base.String.t -> tval nanosecond : tval microsecond : tval millisecond : tval second : tval minute : tval hour : tval day : tval robust_comparison_tolerance : t10^-6 seconds, used in robustly comparable operators (<., >., =., ...) to determine equality
val zero : tval create : ?sign:Sign.t -> ?day:Base.Int.t -> ?hr:Base.Int.t -> ?min:Base.Int.t -> ?sec:Base.Int.t -> ?ms:Base.Int.t -> ?us:Base.Int.t -> ?ns:Base.Int.t -> Base.Unit.t -> t?sign defaults to positive. Setting it to negative is equivalent to negating all the integers.
val of_ns : Base.Float.t -> tval of_us : Base.Float.t -> tval of_ms : Base.Float.t -> tval of_sec : Base.Float.t -> tval of_int_sec : Base.Int.t -> tval of_min : Base.Float.t -> tval of_hr : Base.Float.t -> tval of_day : Base.Float.t -> tval to_ns : t -> Base.Float.tval to_us : t -> Base.Float.tval to_ms : t -> Base.Float.tval to_sec : t -> Base.Float.tval to_min : t -> Base.Float.tval to_hr : t -> Base.Float.tval to_day : t -> Base.Float.tto_int63_seconds_round_down_exn t returns the number of seconds represented by t, rounded down, raising if the result is not representable as an Int63.t.
val to_proportional_float : t -> Base.Float.tThe only condition to_proportional_float is supposed to satisfy is that for all t1, t2 : t: to_proportional_float t1 /. to_proportional_float t2 = t1 // t2.
The arithmetic operations rely on the behavior of the underlying representation of a span. For example, if addition overflows with float-represented spans, the result is an infinite span; with fixed-width integer-represented spans, the result silently wraps around as in two's-complement arithmetic.
val scale : t -> Base.Float.t -> tval (/) : t -> Base.Float.t -> tval (//) : t -> t -> Base.Float.tnext t is the smallest representable span greater than t (and therefore representation-dependent)
prev t is the largest representable span less than t (and therefore representation-dependent)
val to_short_string : t -> Base.String.tto_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 millisecondsonly the most significant denomination is shown.
val to_unit_of_time : t -> Unit_of_time.tto_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 -> tof_unit_of_time unit_of_time produces a t representing the corresponding span.
val to_string_hum : ?delimiter:Base.Char.t -> ?decimals:Base.Int.t -> ?align_decimal:Base.Bool.t -> ?unit_of_time:Unit_of_time.t ->
t -> Base.String.tto_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 of_sec_with_microsecond_precision : Base.Float.t -> tval of_int_us : Base.Int.t -> tval of_int_ms : Base.Int.t -> tval to_int_us : t -> Base.Int.tval to_int_ms : t -> Base.Int.tval to_int_sec : t -> Base.Int.tval min_value_representable : tThe minimum representable time span.
val max_value_representable : tThe maximum representable time span.
val min_value_for_1us_rounding : tThe minimum span that rounds to a Time.Span.t with microsecond precision.
val max_value_for_1us_rounding : tThe maximum span that rounds to a Time.Span.t with microsecond precision.
val min_value : tAn alias for min_value_for_1us_rounding.
val max_value : tAn alias for max_value_for_1us_rounding.
val scale_int : t -> Base.Int.t -> toverflows silently
val to_int_ns : t -> Base.Int.tWill raise on 32-bit platforms. Consider to_int63_ns instead.
val of_int_ns : Base.Int.t -> tval since_unix_epoch : Base.Unit.t -> tval random : ?state:Base.Random.State.t -> Base.Unit.t -> tval to_span : t -> Base.Float.tWARNING!!! to_span and of_span both round to the nearest 1us.
Around 135y magnitudes to_span and of_span raise.
val of_span : Base.Float.t -> t*_round_nearest vs *_round_nearest_microsecond: If you don't know that you need microsecond precision, use the *_round_nearest version. *_round_nearest_microsecond is for historical purposes.
val to_span_float_round_nearest : t -> Base.Float.tval to_span_float_round_nearest_microsecond : t -> Base.Float.tval of_span_float_round_nearest : Base.Float.t -> tval of_span_float_round_nearest_microsecond : Base.Float.t -> tmodule Alternate_sexp : sig ... endNote that we expose a sexp format that is not the one exposed in Core.
module Private : sig ... end