An absolute point in time, more efficient and precise than the float
-based Time,
but representing a narrower range of times.
This module represents absolute times with nanosecond precision, approximately between the years 1823 and 2116 CE.
You should normally default to using Time
instead of this module! The reasons are:
Time.t
values, so it will likely be
much more convenient for you.Time.t
and the other half expecting
Time_ns.t
.Time_ns
silently ignores overflow.Some reasons you might want want to actually prefer Time_ns.t
in certain cases:
int
s rather than float
s internally, which makes certain things easier to
reason about, since int
s respect a bunch of arithmetic identities that float
s
don't, e.g., x + (y + z) = (x + y) + z
.All in all, it would have been nice to have chosen Time_ns.t
to begin with, but
we're unlikely to flip everything to Time_ns.t
in the short term (see comment at the
end of time_ns.ml
).
See Core_kernel.Time_ns for additional low level documentation.
include sig ... end
val typerep_of_t : t Typerep_lib.Std.Typerep.t
val typename_of_t : t Typerep_lib.Std.Typename.t
module Option : sig ... end
Option.t
is like t option
, except that the value is immediate. This module
should mainly be used to avoid allocations.
include Core__.Import.Identifiable with type t := t
include sig ... end
val t_of_sexp : Sexplib.Sexp.t ‑> t
val sexp_of_t : t ‑> Sexplib.Sexp.t
val bin_t : t Bin_prot.Type_class.t
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (Core_kernel__.Import.int ‑> t) Bin_prot.Read.reader
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t
include Core_kernel__.Import.Stringable.S with type t := t
val of_string : string ‑> t
val to_string : t ‑> string
include Core_kernel.Comparable.S_binable with type t := t
include Core_kernel__.Comparable_intf.S_common
include Base.Comparable_intf.S
include Base.Comparable_intf.Polymorphic_compare
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.
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.t
include Base.Comparator.S with type t := t
val comparator : (t, comparator_witness) Base.Comparator.comparator
include Base.Comparable_intf.Validate with type t := t
val validate_lbound : min:t Base.Maybe_bound.t ‑> t Base.Validate.check
val validate_ubound : max:t Base.Maybe_bound.t ‑> t Base.Validate.check
val validate_bound : min:t Base.Maybe_bound.t ‑> max:t Base.Maybe_bound.t ‑> t Base.Validate.check
module Replace_polymorphic_compare : Core_kernel__.Comparable_intf.Polymorphic_compare with type t := t
include Core_kernel__.Comparable_intf.Map_and_set_binable with type t := t with type comparator_witness := comparator_witness
include Core_kernel.Comparator.S with type t := t
val comparator : (t, comparator_witness) Core_kernel.Comparator.comparator
module Map : Core_kernel__.Core_map.S_binable with type Key.t = t with type Key.comparator_witness = comparator_witness
module Set : Core_kernel__.Core_set.S_binable with type Elt.t = t with type Elt.comparator_witness = comparator_witness
include Core_kernel.Hashable.S_binable with type t := t
val hash : t ‑> Core_kernel__.Import.int
val hashable : t Core_kernel.Hashable.Hashtbl.Hashable.t
module Table : Core_kernel.Hashable.Hashtbl.S_binable with type key = t
module Hash_set : Core_kernel.Hash_set.S_binable with type elt = t
module Hash_queue : Core_kernel.Hash_queue.S with type Key.t = t
include Core_kernel__.Import.Pretty_printer.S with type t := t
val pp : Caml.Format.formatter ‑> t ‑> unit
module Zone : module type of Core__.Import_time.Time.Zone with type Zone.t = Core__.Import_time.Time.Zone.t
val min_value : t
val max_value : t
val now : unit ‑> t
val to_time : t ‑> Core__.Import_time.Time.t
val to_string_fix_proto : [ `Utc | `Local ] ‑> t ‑> string
val of_string_fix_proto : [ `Utc | `Local ] ‑> string ‑> t
val of_string_abs : string ‑> t
val to_int63_ns_since_epoch : t ‑> Core__.Import.Int63.t
val of_int63_ns_since_epoch : Core__.Import.Int63.t ‑> t
val to_int_ns_since_epoch : t ‑> int
Will raise on 32-bit platforms. Consider to_int63_ns_since_epoch
instead.
val of_int_ns_since_epoch : int ‑> t
val of_date_ofday : zone:Zone.t ‑> Core__.Import.Date.t ‑> Ofday.t ‑> t
val to_date : t ‑> zone:Zone.t ‑> Core__.Import.Date.t
val to_date_ofday : t ‑> zone:Zone.t ‑> Core__.Import.Date.t * Ofday.t
val occurrence : [ `First_after_or_at | `Last_before_or_at ] ‑> t ‑> ofday:Ofday.t ‑> zone:Core__.Import_time.Time.Zone.t ‑> t
interruptible_pause span
sleeps for span
time unless interrupted (e.g. by
delivery of a signal), in which case the remaining unslept portion of time is
returned.
module Stable : sig ... end
val random : ?state:Core__.Import.Random.State.t ‑> unit ‑> t