Module Core_kernel.Date
Date module.
include Bin_prot.Binable.S with type t := t
include Bin_prot.Binable.S_only_functions with type t := t
val bin_size_t : t Bin_prot.Size.sizerval bin_write_t : t Bin_prot.Write.writerval bin_read_t : t Bin_prot.Read.readerval __bin_read_t__ : (int -> t) Bin_prot.Read.readerThis function only needs implementation if
texposed 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 varianttafterwards.
val bin_shape_t : Bin_prot.Shape.tval bin_writer_t : t Bin_prot.Type_class.writerval bin_reader_t : t Bin_prot.Type_class.readerval bin_t : t Bin_prot.Type_class.t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> tval sexp_of_t : t -> Sexplib0.Sexp.t
include Typerep_lib.Typerepable.S with type t := t
val typerep_of_t : t Typerep_lib.Std_internal.Typerep.tval typename_of_t : t Typerep_lib.Typename.t
include Core_kernel__.Std_internal.Hashable_binable with type t := t
val hash_fold_t : Base.Hash.state -> t -> Base.Hash.stateval hash : t -> Base.Hash.hash_value
val hashable : t Hashtbl.Hashable.t
module Table : Hashtbl.S_binable with type key = tmodule Hash_set : Hash_set.S_binable with type elt = tmodule Hash_queue : Hash_queue.S with type key = tconverts 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__.Std_internal.Stringable with type t := t
include Core_kernel__.Std_internal.Comparable_binable with type t := t
include Core_kernel__.Comparable_intf.S_common
include Base.Comparable.S
include Base__.Comparable_intf.Polymorphic_compare
val ascending : t -> t -> intascendingis identical tocompare.descending x y = ascending y x. These are intended to be mnemonic when used likeList.sort ~compare:ascendingandList.sort ~cmp:descending, since they cause the list to be sorted in ascending or descending order, respectively.
val descending : t -> t -> intval between : t -> low:t -> high:t -> boolbetween t ~low ~highmeanslow <= t <= high
val clamp_exn : t -> min:t -> max:t -> tclamp_exn t ~min ~maxreturnst', the closest value totsuch thatbetween t' ~low:min ~high:maxis 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.checkval validate_ubound : max:t Base.Maybe_bound.t -> t Base.Validate.checkval 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 := tinclude Core_kernel__.Comparable_intf.Map_and_set_binable with type t := t with type comparator_witness := comparator_witness
include Comparator.S with type t := t
val comparator : (t, comparator_witness) Comparator.comparator
module Map : Map.S_binable with type Key.t = t with type Key.comparator_witness = comparator_witnessmodule Set : Set.S_binable with type Elt.t = t with type Elt.comparator_witness = comparator_witnessinclude Core_kernel__.Import.Pretty_printer.S with type t := t
val pp : Base.Formatter.t -> t -> unit
val create_exn : y:Core_kernel__.Import.int -> m:Month.t -> d:Core_kernel__.Import.int -> tcreate_exn ~y ~m ~dcreates 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 : Core_kernel__.Import.string -> pos:Core_kernel__.Import.int -> tFor details on this ISO format, see:
http://www.wikipedia.org/wiki/iso8601
val to_string_iso8601_basic : t -> Core_kernel__.Import.stringYYYYMMDD
val to_string_american : t -> Core_kernel__.Import.stringMM/DD/YYYY
val day : t -> Core_kernel__.Import.intval month : t -> Month.tval year : t -> Core_kernel__.Import.intval day_of_week : t -> Day_of_week.tOnly accurate after 1752-09
val week_number_and_year : t -> Core_kernel__.Import.int * Core_kernel__.Import.intWeek 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 : t -> Core_kernel__.Import.intSee
week_number_and_yearfor the meaning of week number.
val is_weekend : t -> Core_kernel__.Import.boolval is_weekday : t -> Core_kernel__.Import.boolval is_business_day : t -> is_holiday:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.boolMonday through Friday are business days, unless they're a holiday.
val add_days : t -> Core_kernel__.Import.int -> tadd_days t nadds n days totand returns the resulting date.Inaccurate when crossing 1752-09.
val add_months : t -> Core_kernel__.Import.int -> tadd_months t nreturns 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
xmonths and then addingymonths isn't the same as addingx + ymonths, and in particular addingxmonths and then-xmonths won't always get you back where you were. *
val add_years : t -> Core_kernel__.Import.int -> tadd_years t nhas the same semantics asadd_monthsfor 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 : t -> t -> Core_kernel__.Import.intdiff t1 t2returns datet1minus datet2in days.
val diff_weekdays : t -> t -> Core_kernel__.Import.intdiff_weekdays t1 t2returns the number of weekdays in the half-open interval [t2,t1) if t1 >= t2, and- diff_weekdays t2 t1otherwise.
val diff_weekend_days : t -> t -> Core_kernel__.Import.intdiff_weekend_days t1 t2returns the number of days that are weekend days in the half-open interval [t2,t1) if t1 >= t2, and- diff_weekend_days t2 t1otherwise.
val add_weekdays_rounding_backward : t -> Core_kernel__.Import.int -> tFirst rounds the given date backward to the previous weekday, if it is not already a weekday. Then advances by the given number of weekdays, which may be negative.
val add_weekdays_rounding_forward : t -> Core_kernel__.Import.int -> tFirst rounds the given date forward to the next weekday, if it is not already a weekday. Then advances by the given number of weekdays, which may be negative.
val add_business_days_rounding_backward : t -> is_holiday:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.int -> tFirst rounds the given date backward to the previous business day, i.e. weekday not satisfying
is_holiday, if it is not already a business day. Then advances by the given number of business days, which may be negative.
val add_business_days_rounding_forward : t -> is_holiday:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.int -> tFirst rounds the given date forward to the next business day, i.e. weekday not satisfying
is_holiday, if it is not already a business day. Then advances by the given number of business days, which may be negative.
val add_weekdays : t -> Core_kernel__.Import.int -> tadd_weekdays t 0returns the next weekday iftis a weekend andtotherwise. Unlikeadd_daysthis 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 1oradd_weekdays sun 1both return the nexttue, not the nextmon. You may want to usefollowing_weekdayif you want the next following weekday,following_weekday (fri|sat|sun)would all return the nextmon.
val add_weekdays_rounding_in_direction_of_step : t -> Core_kernel__.Import.int -> tval add_business_days : t -> is_holiday:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.int -> tadd_business_days t ~is_holiday nreturns a business day even whenn=0.add_business_days ~is_holiday:(fun _ -> false) ...is the same asadd_weekdays.If you don't want to skip Saturday or Sunday, use
add_days_skipping.
val add_business_days_rounding_in_direction_of_step : t -> is_holiday:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.int -> tval add_days_skipping : t -> skip:(t -> Core_kernel__.Import.bool) -> Core_kernel__.Import.int -> tadd_days_skipping t ~skip naddsndays tot, ignoring any date satisfyingskip, starting at the first date at or aftertthat does not satisfyskip. For example, ifskip t = true, thenadd_days_skipping t ~skip 0 > t.add_business_daysandadd_weekdaysare special cases ofadd_days_skipping.
val dates_between : min:t -> max:t -> t Core_kernel__.Import.listthe following returns a closed interval (endpoints included)
val business_dates_between : min:t -> max:t -> is_holiday:(t -> Core_kernel__.Import.bool) -> t Core_kernel__.Import.listval weekdays_between : min:t -> max:t -> t Core_kernel__.Import.listval previous_weekday : t -> tval following_weekday : t -> tval first_strictly_after : t -> on:Day_of_week.t -> tfirst_strictly_after t ~on:day_of_weekreturns the first occurrence ofday_of_weekstrictly aftert.
val days_in_month : year:Core_kernel__.Import.int -> month:Month.t -> Core_kernel__.Import.intdays_in_month ~year ~monthreturns the number of days inmonth, usingyearonly ifmonth = Month.Febto check if there is a leap year.Incorrect for September 1752.
val is_leap_year : year:Core_kernel__.Import.int -> Core_kernel__.Import.boolis_leap_year ~yearreturns true ifyearis considered a leap year
val unix_epoch : tThe starting date of the UNIX epoch: 1970-01-01
gen generates dates between 1900-01-01 and 2100-01-01.
include Core_kernel__.Std_internal.Quickcheckable with type t := t
val quickcheck_generator : t Base_quickcheck.Generator.tval quickcheck_observer : t Base_quickcheck.Observer.tval quickcheck_shrinker : t Base_quickcheck.Shrinker.t
val gen_incl : t -> t -> t Quickcheck.Generator.tgen_incl d1 d2generates dates in the range betweend1andd2, inclusive, with the endpoints having higher weight than the rest. Raises ifd1 > d2.
val gen_uniform_incl : t -> t -> t Quickcheck.Generator.tgen_uniform_incl d1 d2generates dates chosen uniformly in the range betweend1andd2, inclusive. Raises ifd1 > d2.
module Days : sig ... end with type date := tDaysprovides 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 ordinaryt.
module Option : sig ... endmodule Stable : sig ... endmodule O : sig ... endmodule Private : sig ... endval of_time : Core_kernel__.Time_float.t -> zone:Core_kernel__.Time_float.Zone.t -> tval today : zone:Core_kernel__.Time_float.Zone.t -> t