package core

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include Typerep_lib.Typerepable.S with type t := t
val typerep_of_t : t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : t Typerep_lib.Typename.t
module Span : sig ... end
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 : sig ... end

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_kernel.Identifiable with type t := t
include Bin_prot.Binable.S with type t := 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
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> t
include Core_kernel.Identifiable.S_common with type t := t
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val of_string : string -> t
val to_string : t -> string
val pp : Base__.Formatter.t -> t -> unit
include Core_kernel.Comparable.S_binable with type t := t
include Base.Comparable.S with type 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 equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
type comparator_witness
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 : sig ... end
include Core_kernel.Hashable.S_binable with type t := t
val hash_fold_t : Ppx_hash_lib.Std.Hash.state -> t -> Ppx_hash_lib.Std.Hash.state
val hash : t -> Ppx_hash_lib.Std.Hash.hash_value
val hashable : t Core_kernel__.Hashtbl.Hashable.t
module Hash_queue : Core_kernel.Hash_queue.S with type Key.t = t
module Zone : sig ... end

These functions are identical to those in Time and get/set the same variable.

val get_sexp_zone : unit -> Zone.t
val set_sexp_zone : Zone.t -> unit
val t_of_sexp_abs : Core_kernel.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_kernel.Sexp.t
val epoch : t

Unix epoch (1970-01-01 00:00:00 UTC)

val min_value : t
val max_value : t
val now : unit -> t
val add : t -> Span.t -> t

overflows silently

val sub : t -> Span.t -> t

overflows silently

val next : t -> t

overflows silently

val prev : t -> t

overflows silently

val diff : t -> t -> Span.t

overflows silently

val abs_diff : t -> t -> Span.t

overflows silently

val to_span_since_epoch : t -> Span.t
val of_span_since_epoch : Span.t -> t
val to_time : t -> Core_kernel.Time.t
  • deprecated [since 2019-01] use [to_time_float_round_nearest] or [to_time_float_round_nearest_microsecond]
val of_time : Core_kernel.Time.t -> t
  • deprecated [since 2019-01] use [of_time_float_round_nearest] or [of_time_float_round_nearest_microsecond]
val to_time_float_round_nearest : t -> Core_kernel.Time.t
val to_time_float_round_nearest_microsecond : t -> Core_kernel.Time.t
val of_time_float_round_nearest : Core_kernel.Time.t -> t
val of_time_float_round_nearest_microsecond : Core_kernel.Time.t -> t
val to_string_fix_proto : [ `Utc | `Local ] -> t -> string
val of_string_fix_proto : [ `Utc | `Local ] -> string -> t
val to_string_abs : t -> zone:Zone.t -> string

to_string_abs ~zone t is the same as to_string t except that it uses the given time zone.

val to_string_abs_trimmed : t -> zone:Zone.t -> string

to_string_abs_trimmed is the same as to_string_abs, but drops trailing seconds and milliseconds if they are 0.

val to_string_abs_parts : t -> zone:Zone.t -> string list
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 to_string_trimmed : t -> zone:Zone.t -> string

Same as to_string_abs_trimmed, except it leaves off the timezone, so won't reliably round trip.

val to_sec_string : t -> zone:Zone.t -> string

Same as to_string_abs, but without milliseconds

val of_localized_string : zone:Zone.t -> string -> t

of_localized_string ~zone str read in the given string assuming that it represents a time in zone and return the appropriate Time_ns.t

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 to_string_iso8601_basic : t -> zone:Zone.t -> string

to_string_iso8601_basic returns a string representation of the following form: %Y-%m-%dT%H:%M:%S.%s%Z e.g. to_string_iso8601_basic ~zone:Time.Zone.utc epoch = "1970-01-01T00:00:00.000000000Z"

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 -> int

Will raise on 32-bit platforms. Consider to_int63_ns_since_epoch instead.

val of_int_ns_since_epoch : int -> t
val to_filename_string : t -> zone:Zone.t -> string

to_filename_string t ~zone converts t to string with format YYYY-MM-DD_HH-MM-SS.mmm which is suitable for using in filenames.

val of_filename_string : string -> zone:Zone.t -> t

of_filename_string s ~zone converts s that has format YYYY-MM-DD_HH-MM-SS.mmm into time_ns.

val next_multiple : ?can_equal_after:bool -> base:t -> after:t -> interval:Span.t -> unit -> t

See Core_kernel.Time_ns.

Overflows silently.

val prev_multiple : ?can_equal_before:bool -> base:t -> before:t -> interval:Span.t -> unit -> t

See Core_kernel.Time_ns.

Overflows silently.

val of_date_ofday : zone:Zone.t -> Core__.Import.Date.t -> Ofday.t -> t
val of_date_ofday_precise : Core__.Import.Date.t -> Ofday.t -> zone:Zone.t -> [ `Once of t | `Twice of t * t | `Never of t ]

Because timezone offsets change throughout the year (clocks go forward or back) some local times can occur twice or not at all. In the case that they occur twice, this function gives `Twice with both occurrences in order; if they do not occur at all, this function gives `Never with the time at which the local clock skips over the desired time of day.

Note that this is really only intended to work with DST transitions and not unusual or dramatic changes, like the calendar change in 1752 (run "cal 9 1752" in a shell to see). In particular it makes the assumption that midnight of each day is unambiguous.

Most callers should use of_date_ofday rather than this function. In the `Twice and `Never cases, of_date_ofday will return reasonable times for most uses.

val to_ofday : t -> zone:Zone.t -> Ofday.t
val to_date_ofday_precise : t -> zone:Zone.t -> Core__.Import.Date.t * Ofday.t * [ `Only | `Also_at of t | `Also_skipped of Core__.Import.Date.t * Ofday.t ]

Always returns the Date.t * Ofday.t that to_date_ofday would have returned, and in addition returns a variant indicating whether the time is associated with a time zone transition.

      - `Only         -> there is a one-to-one mapping between [t]'s and
                         [Date.t * Ofday.t] pairs
      - `Also_at      -> there is another [t] that maps to the same [Date.t * Ofday.t]
                         (this date/time pair happened twice because the clock fell back)
      - `Also_skipped -> there is another [Date.t * Ofday.t] pair that never happened (due
                         to a jump forward) that [of_date_ofday] would map to the same
                         [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_kernel__.Zone.t -> t
val reset_date_cache : unit -> unit

For performance testing only; reset_date_cache () resets an internal cache used to speed up to_date and related functions when called repeatedly on times that fall within the same day.

val convert : from_tz:Zone.t -> to_tz:Zone.t -> Core__.Import.Date.t -> Ofday.t -> Core__.Import.Date.t * Ofday.t

It's unspecified what happens if the given date/ofday/zone correspond to more than one date/ofday pair in the other zone.

val utc_offset : t -> zone:Zone.t -> Span.t
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_kernel.Nothing.t

pause_forever sleeps indefinitely.

module Stable : sig ... end
val random : ?state:Core__.Import.Random.State.t -> unit -> t
OCaml

Innovation. Community. Security.