Module type Time_ns_intf.Time_ns

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:

Some reasons you might want want to actually prefer Time_ns.t in certain cases:

Neither Core.Time_ns nor Core.Time are available in Javascript.

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 module type of sig ... end with module Span := Core__.Import.Time_ns.Span with module Ofday := Core__.Import.Time_ns.Ofday with module Stable := Core__.Import.Time_ns.Stable
type t = Core_kernel__Time_ns.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
val typerep_of_t : t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : t Typerep_lib.Typename.t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader
val bin_shape_t : Bin_prot.Shape.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_t : t Bin_prot.Type_class.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 quickcheck_generator : t Base_quickcheck.Generator.t
val quickcheck_observer : t Base_quickcheck.Observer.t
val quickcheck_shrinker : t Base_quickcheck.Shrinker.t
val gen_incl : t -> t -> t Base_quickcheck.Generator.t
val gen_uniform_incl : t -> t -> t Base_quickcheck.Generator.t
val is_earlier : t -> than:t -> Core_kernel__.Import.bool
val is_later : t -> than:t -> Core_kernel__.Import.bool
val of_date_ofday : zone:Core_kernel__.Zone.t -> Core_kernel__.Time_intf.Date.t -> Ofday.t -> t
val of_date_ofday_precise : Core_kernel__.Time_intf.Date.t -> Ofday.t -> zone:Core_kernel__.Zone.t -> [ `Never of t | `Once of t | `Twice of t * t ]
val to_date_ofday : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Time_intf.Date.t * Ofday.t
val to_date_ofday_precise : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Time_intf.Date.t * Ofday.t * [ `Also_at of t | `Also_skipped of Core_kernel__.Time_intf.Date.t * Ofday.t | `Only ]
val to_date : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Time_intf.Date.t
val to_ofday : t -> zone:Core_kernel__.Zone.t -> Ofday.t
val reset_date_cache : Core_kernel__.Import.unit -> Core_kernel__.Import.unit
val convert : from_tz:Core_kernel__.Zone.t -> to_tz:Core_kernel__.Zone.t -> Core_kernel__.Time_intf.Date.t -> Ofday.t -> Core_kernel__.Time_intf.Date.t * Ofday.t
val utc_offset : t -> zone:Core_kernel__.Zone.t -> Span.t
val of_string : string -> t
val to_string : t -> string
val to_filename_string : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val of_filename_string : Core_kernel__.Import.string -> zone:Core_kernel__.Zone.t -> t
val to_string_abs : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val to_string_abs_trimmed : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val to_string_abs_parts : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string Core_kernel__.Import.list
val to_string_trimmed : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val to_sec_string : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val of_localized_string : zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string -> t
val of_string_gen : default_zone:(Core_kernel__.Import.unit -> Core_kernel__.Zone.t) -> find_zone:(Core_kernel__.Import.string -> Core_kernel__.Zone.t) -> Core_kernel__.Import.string -> t
val to_string_iso8601_basic : t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Import.string
val occurrence : [ `First_after_or_at | `Last_before_or_at ] -> t -> ofday:Ofday.t -> zone:Core_kernel__.Zone.t -> t
val epoch : t
val min_value_representable : t
val max_value_representable : t
val min_value_for_1us_rounding : t
val max_value_for_1us_rounding : t
val min_value : t
val max_value : t
val now : Core_kernel__.Import.unit -> t
val add : t -> Span.t -> t
val add_saturating : t -> Span.t -> t
val sub_saturating : t -> Span.t -> t
val sub : t -> Span.t -> t
val next : t -> t
val prev : t -> t
val diff : t -> t -> Span.t
val abs_diff : t -> t -> Span.t
val to_span_since_epoch : t -> Span.t
val of_span_since_epoch : Span.t -> t
val to_int63_ns_since_epoch : t -> Core_kernel.Int63.t
val of_int63_ns_since_epoch : Core_kernel.Int63.t -> t
val to_int_ns_since_epoch : t -> Core_kernel__.Import.int
val of_int_ns_since_epoch : Core_kernel__.Import.int -> t
val next_multiple : ?⁠can_equal_after:Core_kernel__.Import.bool -> base:t -> after:t -> interval:Span.t -> Core_kernel__.Import.unit -> t
val prev_multiple : ?⁠can_equal_before:Core_kernel__.Import.bool -> base:t -> before:t -> interval:Span.t -> Core_kernel__.Import.unit -> t
val random : ?⁠state:Core_kernel__.Import.Random.State.t -> Core_kernel__.Import.unit -> t
val of_time : Core_kernel__.Time_float.t -> t
val to_time : t -> Core_kernel__.Time_float.t
val to_time_float_round_nearest : t -> Core_kernel__.Time_float.t
val to_time_float_round_nearest_microsecond : t -> Core_kernel__.Time_float.t
val of_time_float_round_nearest : Core_kernel__.Time_float.t -> t
val of_time_float_round_nearest_microsecond : Core_kernel__.Time_float.t -> t
module Span : Span
val arg_type : t Core_kernel.Command.Arg_type.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.

module Ofday : Ofday

See Time.Ofday.

String conversions use the local timezone by default. Sexp conversions use get_sexp_zone () by default, which can be overridden by calling set_sexp_zone. These default time zones are used when writing a time, and when reading a time with no explicit zone or UTC offset.

Sexps and strings display the date, ofday, and UTC offset of t relative to the appropriate time zone.

include Core__.Import.Identifiable with type t := t
type t
include Bin_prot.Binable.S with type t := t
type t
include Bin_prot.Binable.S_only_functions with type t := t
type t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader

This 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.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_t : t Bin_prot.Type_class.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
type t
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
include Core_kernel.Identifiable.S_common with type t := t
type t
val compare : t -> t -> Core_kernel__.Import.int
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
include Core_kernel__.Import.Stringable.S with type t := t
type t
val of_string : string -> t
val to_string : t -> string
include Core_kernel__.Import.Pretty_printer.S with type t := t
type t
val pp : Base.Formatter.t -> t -> unit
include Core_kernel.Comparable.S_binable with type t := t
include Core_kernel__.Comparable_intf.S_common
include Base.Comparable.S
include Base__.Comparable_intf.Polymorphic_compare
include Base.Comparisons.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

compare 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.

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 ~compare: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

between t ~low ~high means low <= t <= high

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 Base.Or_error.t
include Base.Comparator.S with type t := t
type t
type comparator_witness
val comparator : (tcomparator_witness) Base.Comparator.comparator
include Base__.Comparable_intf.Validate with type t := t
type 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
include Core_kernel.Hashable.S_binable with type t := t
type t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
val hash : t -> Base.Hash.hash_value
val hashable : t Core_kernel.Hashtbl.Hashable.t
module Zone : module type of Core__.Import_time.Time.Zone with type Zone.t = Core__.Import_time.Time.Zone.t
val get_sexp_zone : unit -> Zone.t
val set_sexp_zone : Zone.t -> unit
val t_of_sexp_abs : Core__.Import.Sexp.t -> t

t_of_sexp_abs sexp as t_of_sexp, but demands that sexp indicate the timezone the time is expressed in.

val sexp_of_t_abs : t -> zone:Zone.t -> Core__.Import.Sexp.t
val of_date_ofday_zoned : Core__.Import.Date.t -> Ofday.Zoned.t -> t

Conversion functions that involved Ofday.Zoned.t, exactly analogous to the conversion functions that involve Ofday.t

val to_date_ofday_zoned : t -> zone:Core__.Import_time.Time.Zone.t -> Core__.Import.Date.t * Ofday.Zoned.t
val to_ofday_zoned : t -> zone:Core__.Import_time.Time.Zone.t -> Ofday.Zoned.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

This is like of_string except that if the string doesn't specify the zone then it raises rather than assume the local timezone.

val of_string_gen : if_no_timezone:[ `Fail | `Local | `Use_this_one of Zone.t ] -> string -> t

of_string_gen ~if_no_timezone s attempts to parse s to a t. If s doesn't supply a time zone if_no_timezone is consulted.

val pause : Span.t -> unit

pause span sleeps for span time.

val interruptible_pause : Span.t -> [ `Ok | `Remaining of Span.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.

val pause_forever : unit -> Core__.Import.never_returns

pause_forever sleeps indefinitely.

module Stable : sig ... end