package core_extended

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include module type of struct include Core.Date end
include module type of Core_kernel.Date with type t := t
include sig ... end
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (Base.Int.t -> 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
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
include Core_kernel.Interfaces.Hashable_binable with type t := t
val hash : t -> Base.Int.t
module Table = Core.Date.Table
module Hash_set = Core.Date.Hash_set
module Hash_queue = Core.Date.Hash_queue

converts a string to a date, in formats: * m/d/y * y-m-d (* valid iso8601_extended *) * DD MMM YYYY * DDMMMYYYY * YYYYMMDD

include Core_kernel.Interfaces.Stringable with type t := t
val of_string : string -> t
val to_string : t -> string
include Core_kernel.Interfaces.Comparable_binable with type t := t
include Base.Comparable_intf.S with type t := t
include Base.Comparable_intf.Polymorphic_compare with type t := t
include Base.Polymorphic_compare_intf.Infix 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

-1 means "less than", 0 means "equal", 1 means "greater than", and other values should not be returned

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 ~cmp: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
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 comparator_witness = Core.Date.comparator_witness
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.Date.Replace_polymorphic_compare
module Map = Core.Date.Map
module Set = Core.Date.Set
include Base.Pretty_printer.S with type t := t
val pp : Caml.Format.formatter -> t -> unit
val create_exn : y:Base.Int.t -> m:Core_kernel.Month.t -> d:Base.Int.t -> 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 -> t

For details on this ISO format, see:

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

YYYYMMDD

val to_string_iso8601_basic : t -> Base.String.t

YYYYMMDD

val to_string_american : t -> Base.String.t

MM/DD/YYYY

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

Week of the year, from 1 to 53. 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. Notice that this means that dates near the end of the year can have week number 1, and dates near the beginning of the year can have week number 52 or 53.

Warning: the triple (year, week number, week day) does not identify a date -- e.g. 2012-01-02 and 2012-12-31 are both Mondays of week 1. (However, if instead of the year, you use the year of the nearest Thursday, then it does work.)

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

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

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

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

val add_months : t -> Base.Int.t -> 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. *

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

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

val diff_weekdays : t -> 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 : t -> 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 : t -> Base.Int.t -> 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 : t -> is_holiday:(t -> Base.Bool.t) -> Base.Int.t -> 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.

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

the following returns a closed interval (endpoints included)

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

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

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

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

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

include Core_kernel.Interfaces.Quickcheckable with type t := 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 : t -> t -> 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 Stable = Core.Date.Stable
module O = Core.Date.O
val of_time : float -> zone:Core_kernel__.Time_float.Zone.t -> t
val today : zone:Core_kernel__.Time_float.Zone.t -> t
val parse : fmt:string -> string -> t

This parses a date using the format patterns available in strptime.

val of_tm : Unix.tm -> t
include module type of struct include Extended_time.Extended_date end
val format : ?ofday:Core.Time.Ofday.t -> string -> Core.Date.t -> string

Shortcut for calling Core_extended.Unix.strftime without having to create a Time.t and convert it to a Unix.tm.

format "%Y-%m-%d" t will return "YYYY-MM-DD"

OCaml

Innovation. Community. Security.