package async

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Core_kernel.Date end
include Bin_prot.Binable.S with type t := Core_kernel__.Date0.t
include Bin_prot.Binable.S_only_functions with type t := Core_kernel__.Date0.t
val bin_size_t : Core_kernel__.Date0.t Bin_prot.Size.sizer
val bin_write_t : Core_kernel__.Date0.t Bin_prot.Write.writer
val bin_read_t : Core_kernel__.Date0.t Bin_prot.Read.reader
val __bin_read_t__ : (int -> Core_kernel__.Date0.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 : Core_kernel__.Date0.t Bin_prot.Type_class.writer
val bin_reader_t : Core_kernel__.Date0.t Bin_prot.Type_class.reader
val bin_t : Core_kernel__.Date0.t Bin_prot.Type_class.t
include Ppx_sexp_conv_lib.Sexpable.S with type t := Core_kernel__.Date0.t
val t_of_sexp : Sexplib0.Sexp.t -> Core_kernel__.Date0.t
val sexp_of_t : Core_kernel__.Date0.t -> Sexplib0.Sexp.t
include Typerep_lib.Typerepable.S with type t := Core_kernel__.Date0.t
val typerep_of_t : Core_kernel__.Date0.t Typerep_lib.Std_internal.Typerep.t
val typename_of_t : Core_kernel__.Date0.t Typerep_lib.Typename.t
include Core_kernel.Interfaces.Hashable_binable with type t := Core_kernel__.Date0.t
val hash_fold_t : Base.Hash.state -> Core_kernel__.Date0.t -> Base.Hash.state
val hash : Core_kernel__.Date0.t -> Base.Hash.hash_value
val hashable : Core_kernel__.Date0.t Base.Hashable.t
module Table = Core_kernel.Date.Table
module Hash_set = Core_kernel.Date.Hash_set
module Hash_queue = Core_kernel.Date.Hash_queue

converts a string to a date in the following formats:

  • m/d/y
  • y-m-d (valid iso8601_extended)
  • DD MMM YYYY
  • DDMMMYYYY
  • YYYYMMDD
include Core_kernel.Interfaces.Stringable with type t := Core_kernel__.Date0.t
val of_string : string -> Core_kernel__.Date0.t
val to_string : Core_kernel__.Date0.t -> string
include Core_kernel.Interfaces.Comparable_binable with type t := Core_kernel__.Date0.t
include Base.Comparable.S with type t := Core_kernel__.Date0.t
include Base.Comparisons.S with type t := Core_kernel__.Date0.t
include Base.Comparisons.Infix with type t := Core_kernel__.Date0.t
val (>=) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val (<=) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val (=) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val (>) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val (<) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val (<>) : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val equal : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> bool
val compare : Core_kernel__.Date0.t -> Core_kernel__.Date0.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 : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Core_kernel__.Date0.t
val max : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Core_kernel__.Date0.t
val ascending : Core_kernel__.Date0.t -> Core_kernel__.Date0.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 : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> int
val between : Core_kernel__.Date0.t -> low:Core_kernel__.Date0.t -> high:Core_kernel__.Date0.t -> bool

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

val clamp_exn : Core_kernel__.Date0.t -> min:Core_kernel__.Date0.t -> max:Core_kernel__.Date0.t -> Core_kernel__.Date0.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 : Core_kernel__.Date0.t -> min:Core_kernel__.Date0.t -> max:Core_kernel__.Date0.t -> Core_kernel__.Date0.t Base.Or_error.t
include Base.Comparator.S with type t := Core_kernel__.Date0.t
type comparator_witness = Core_kernel.Date.comparator_witness
val validate_lbound : min:Core_kernel__.Date0.t Base.Maybe_bound.t -> Core_kernel__.Date0.t Base.Validate.check
val validate_ubound : max:Core_kernel__.Date0.t Base.Maybe_bound.t -> Core_kernel__.Date0.t Base.Validate.check
val validate_bound : min:Core_kernel__.Date0.t Base.Maybe_bound.t -> max:Core_kernel__.Date0.t Base.Maybe_bound.t -> Core_kernel__.Date0.t Base.Validate.check
module Replace_polymorphic_compare = Core_kernel.Date.Replace_polymorphic_compare
include Core_kernel.Comparator.S with type t := Core_kernel__.Date0.t with type comparator_witness := comparator_witness
val comparator : (Core_kernel__.Date0.t, comparator_witness) Base.Comparator.comparator
include Base.Pretty_printer.S with type t := Core_kernel__.Date0.t
val pp : Base.Formatter.t -> Core_kernel__.Date0.t -> unit
val create_exn : y:Base.Int.t -> m:Core_kernel.Month.t -> d:Base.Int.t -> Core_kernel__.Date0.t

create_exn ~y ~m ~d creates the date specified in the arguments. Arguments are validated, and are not normalized in any way. So, days must be within the limits for the month in question, numbers cannot be negative, years must be fully specified, etc.

val of_string_iso8601_basic : Base.String.t -> pos:Base.Int.t -> Core_kernel__.Date0.t

For details on this ISO format, see:

http://www.wikipedia.org/wiki/iso8601

val to_string_iso8601_basic : Core_kernel__.Date0.t -> Base.String.t

YYYYMMDD

val to_string_american : Core_kernel__.Date0.t -> Base.String.t

MM/DD/YYYY

val day : Core_kernel__.Date0.t -> Base.Int.t
val month : Core_kernel__.Date0.t -> Core_kernel.Month.t
val year : Core_kernel__.Date0.t -> Base.Int.t
val day_of_week : Core_kernel__.Date0.t -> Core_kernel.Day_of_week.t

Only accurate after 1752-09

val week_number_and_year : Core_kernel__.Date0.t -> Base.Int.t * Base.Int.t

Week of the year, from 1 to 53, along with the week-numbering year to which the week belongs. The week-numbering year may not correspond to the calendar year in which the provided date occurs.

According to ISO 8601, weeks start on Monday, and the first week of a year is the week that contains the first Thursday of the year. This means that dates near the end of the calendar year can have week number 1 and belong to the following week-numbering year, and dates near the beginning of the calendar year can have week number 52 or 53 and belong to the previous week-numbering year.

The triple (week-numbering year, week number, week day) uniquely identifies a particular date, which is not true if the calendar year is used instead.

val week_number : Core_kernel__.Date0.t -> Base.Int.t

See week_number_and_year for the meaning of week number.

val is_weekend : Core_kernel__.Date0.t -> Base.Bool.t
val is_weekday : Core_kernel__.Date0.t -> Base.Bool.t
val is_business_day : Core_kernel__.Date0.t -> is_holiday:(Core_kernel__.Date0.t -> Base.Bool.t) -> Base.Bool.t

Monday through Friday are business days, unless they're a holiday.

val add_days : Core_kernel__.Date0.t -> Base.Int.t -> Core_kernel__.Date0.t

add_days t n adds n days to t and returns the resulting date.

Inaccurate when crossing 1752-09.

val add_months : Core_kernel__.Date0.t -> Base.Int.t -> Core_kernel__.Date0.t

add_months t n returns date with max days for the month if the date would be invalid. e.g. adding 1 month to Jan 30 results in Feb 28 due to Feb 30 being an invalid date, Feb 29 is returned in cases of leap year.

In particular, this means adding x months and then adding y months isn't the same as adding x + y months, and in particular adding x months and then -x months won't always get you back where you were. *

val add_years : Core_kernel__.Date0.t -> Base.Int.t -> Core_kernel__.Date0.t

add_years t n has the same semantics as add_months for adding years to Feb 29 of a leap year, i.e., when the addition results in a date in a non-leap year, the result will be Feb 28 of that year.

val diff : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Base.Int.t

diff t1 t2 returns date t1 minus date t2 in days.

val diff_weekdays : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Base.Int.t

diff_weekdays t1 t2 returns the number of weekdays in the half-open interval [t2,t1) if t1 >= t2, and - diff_weekdays t2 t1 otherwise.

val diff_weekend_days : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Base.Int.t

diff_weekend_days t1 t2 returns the number of days that are weekend days in the half-open interval [t2,t1) if t1 >= t2, and - diff_weekend_days t2 t1 otherwise.

val add_weekdays : Core_kernel__.Date0.t -> Base.Int.t -> Core_kernel__.Date0.t

add_weekdays t 0 returns the next weekday if t is a weekend and t otherwise. Unlike add_days this is done by looping over the count of days to be added (forward or backwards based on the sign), and is O(n) in the number of days to add. Beware, add_weekdays sat 1 or add_weekdays sun 1 both return the next tue, not the next mon. You may want to use following_weekday if you want the next following weekday, following_weekday (fri|sat|sun) would all return the next mon.

val add_business_days : Core_kernel__.Date0.t -> is_holiday:(Core_kernel__.Date0.t -> Base.Bool.t) -> Base.Int.t -> Core_kernel__.Date0.t

add_business_days t ~is_holiday n returns a business day even when n=0. add_business_days ~is_holiday:(fun _ -> false) ... is the same as add_weekdays.

If you don't want to skip Saturday or Sunday, use add_days_skipping.

val add_days_skipping : Core_kernel__.Date0.t -> skip:(Core_kernel__.Date0.t -> Base.Bool.t) -> Base.Int.t -> Core_kernel__.Date0.t

add_days_skipping t ~skip n adds n days to t, ignoring any date satisfying skip, starting at the first date at or after t that does not satisfy skip. For example, if skip t = true, then add_days_skipping t ~skip 0 > t.

add_business_days and add_weekdays are special cases of add_days_skipping.

val dates_between : min:Core_kernel__.Date0.t -> max:Core_kernel__.Date0.t -> Core_kernel__.Date0.t Base.List.t

the following returns a closed interval (endpoints included)

val business_dates_between : min:Core_kernel__.Date0.t -> max:Core_kernel__.Date0.t -> is_holiday:(Core_kernel__.Date0.t -> Base.Bool.t) -> Core_kernel__.Date0.t Base.List.t
val weekdays_between : min:Core_kernel__.Date0.t -> max:Core_kernel__.Date0.t -> Core_kernel__.Date0.t Base.List.t
val previous_weekday : Core_kernel__.Date0.t -> Core_kernel__.Date0.t
val following_weekday : Core_kernel__.Date0.t -> Core_kernel__.Date0.t
val first_strictly_after : Core_kernel__.Date0.t -> on:Core_kernel.Day_of_week.t -> Core_kernel__.Date0.t

first_strictly_after t ~on:day_of_week returns the first occurrence of day_of_week strictly after t.

val days_in_month : year:Base.Int.t -> month:Core_kernel.Month.t -> Base.Int.t

days_in_month ~year ~month returns the number of days in month, using year only if month = Month.Feb to check if there is a leap year.

Incorrect for September 1752.

val is_leap_year : year:Base.Int.t -> Base.Bool.t

is_leap_year ~year returns true if year is considered a leap year

val unix_epoch : Core_kernel__.Date0.t

The starting date of the UNIX epoch: 1970-01-01

gen generates dates between 1900-01-01 and 2100-01-01.

include Core_kernel.Interfaces.Quickcheckable with type t := Core_kernel__.Date0.t
val quickcheck_generator : Core_kernel__.Date0.t Base_quickcheck.Generator.t
val quickcheck_observer : Core_kernel__.Date0.t Base_quickcheck.Observer.t
val quickcheck_shrinker : Core_kernel__.Date0.t Base_quickcheck.Shrinker.t
val gen_incl : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Core_kernel__.Date0.t Core_kernel.Quickcheck.Generator.t

gen_incl d1 d2 generates dates in the range between d1 and d2, inclusive, with the endpoints having higher weight than the rest. Raises if d1 > d2.

val gen_uniform_incl : Core_kernel__.Date0.t -> Core_kernel__.Date0.t -> Core_kernel__.Date0.t Core_kernel.Quickcheck.Generator.t

gen_uniform_incl d1 d2 generates dates chosen uniformly in the range between d1 and d2, inclusive. Raises if d1 > d2.

module Days = Core_kernel.Date.Days

Days provides a linear representation of dates that is optimized for arithmetic on the number of days between dates, rather than for representing year/month/day components. This module is intended for use only in performance-sensitive contexts where dates are manipulated more often than they are constructed or deconstructed; most clients should use the ordinary t.

module Stable = Core_kernel.Date.Stable
module Private = Core_kernel.Date.Private
val of_time : Base.Float.t -> zone:Core_kernel__.Zone.t -> Core_kernel__.Date0.t
val today : zone:Time.Zone.t -> t
  • deprecated [since 2019-05] Use [Time_source]
OCaml

Innovation. Community. Security.