123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272open!ImportopenStd_internalmoduletypeDate0=sigtypet[@@immediate][@@derivingbin_io,hash,sexp,sexp_grammar,typerep]includeHashable_binablewithtypet:=t(** converts a string to a date in the following formats:
- m/d/y
- y-m-d (valid iso8601_extended)
- DD MMM YYYY
- DDMMMYYYY
- YYYYMMDD *)includeStringablewithtypet:=tincludeComparable_binablewithtypet:=tincludePretty_printer.Swithtypet:=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. *)valcreate_exn:y:int->m:Month.t->d:int->t(** For details on this ISO format, see:
http://www.wikipedia.org/wiki/iso8601
*)valof_string_iso8601_basic:string->pos:int->t(** YYYYMMDD *)valto_string_iso8601_basic:t->string(** MM/DD/YYYY *)valto_string_american:t->stringvalday:t->intvalmonth:t->Month.tvalyear:t->int(** Only accurate after 1752-09 *)valday_of_week:t->Day_of_week.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.
*)valweek_number_and_year:t->int*int(** See {!week_number_and_year} for the meaning of week number. *)valweek_number:t->intvalis_weekend:t->boolvalis_weekday:t->bool(** Monday through Friday are business days, unless they're a holiday.
*)valis_business_day:t->is_holiday:(t->bool)->bool(** [add_days t n] adds n days to [t] and returns the resulting date.
Inaccurate when crossing 1752-09.
*)valadd_days:t->int->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. **)valadd_months:t->int->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. *)valadd_years:t->int->t(** [diff t1 t2] returns date [t1] minus date [t2] in days. *)valdiff:t->t->int(** [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. *)valdiff_weekdays:t->t->int(** [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. *)valdiff_weekend_days:t->t->int(** First 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. *)valadd_weekdays_rounding_backward:t->int->t(** First 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. *)valadd_weekdays_rounding_forward:t->int->t(** First 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. *)valadd_business_days_rounding_backward:t->is_holiday:(t->bool)->int->t(** First 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. *)valadd_business_days_rounding_forward:t->is_holiday:(t->bool)->int->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]. *)valadd_weekdays:t->int->t[@@deprecated"[since 2019-12] use [add_weekdays_rounding_backward] or \
[add_weekdays_rounding_forward] as appropriate"]valadd_weekdays_rounding_in_direction_of_step:t->int->t[@@alertlegacy"use [add_weekdays_rounding_backward] or [add_weekdays_rounding_forward] as \
appropriate"](** [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].
*)valadd_business_days:t->is_holiday:(t->bool)->int->t[@@deprecated"[since 2019-12] use [add_business_days_rounding_backward] or \
[add_business_days_rounding_forward] as appropriate"]valadd_business_days_rounding_in_direction_of_step:t->is_holiday:(t->bool)->int->t[@@alertlegacy"use [add_business_days_rounding_backward] or \
[add_business_days_rounding_forward] as appropriate"](** [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]. *)valadd_days_skipping:t->skip:(t->bool)->int->t(** the following returns a closed interval (endpoints included) *)valdates_between:min:t->max:t->tlistvalbusiness_dates_between:min:t->max:t->is_holiday:(t->bool)->tlistvalweekdays_between:min:t->max:t->tlistvalprevious_weekday:t->tvalfollowing_weekday:t->t(** [first_strictly_after t ~on:day_of_week] returns the first occurrence of [day_of_week]
strictly after [t]. *)valfirst_strictly_after:t->on:Day_of_week.t->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. *)valdays_in_month:year:int->month:Month.t->int(** [is_leap_year ~year] returns true if [year] is considered a leap year *)valis_leap_year:year:int->bool(** The starting date of the UNIX epoch: 1970-01-01 *)valunix_epoch:t(** [gen] generates dates between 1900-01-01 and 2100-01-01. *)includeQuickcheckablewithtypet:=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]. *)valgen_incl:t->t->tQuickcheck.Generator.t(** [gen_uniform_incl d1 d2] generates dates chosen uniformly in the range between [d1]
and [d2], inclusive. Raises if [d1 > d2]. *)valgen_uniform_incl:t->t->tQuickcheck.Generator.t(** [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]. *)moduleDays:sigtypedate=ttypet[@@immediate]valof_date:date->tvalto_date:t->datevaldiff:t->t->intvaladd_days:t->int->t(** The starting date of the UNIX epoch: 1970-01-01 *)valunix_epoch:tendwithtypedate:=tmoduleOption:sigtypevalue:=ttypet[@@immediate][@@derivingsexp_grammar]includeImmediate_option_intf.Swithtypevalue:=valueandtypet:=tincludeComparable.S_plainwithtypet:=tincludeQuickcheckable.Swithtypet:=tendmoduleStable:sigmoduleV1:sigtypenonrect=t[@@immediate][@@derivingequal,hash,sexp_grammar](** [to_int] and [of_int_exn] convert to/from the underlying integer
representation. *)valto_int:t->intvalof_int_exn:int->tincludeStable_comparable.V1withtypet:=twithtypecomparator_witness=comparator_witnessincludeHashable.Stable.V1.Swithtypekey:=tendmoduleOption:sigmoduleV1:sigtypenonrect=Option.t[@@immediate][@@derivingbin_io,compare,sexp,sexp_grammar]endendendmoduleO:sigincludeComparable.Infixwithtypet:=tend(*_ See the Jane Street Style Guide for an explanation of [Private] submodules:
https://opensource.janestreet.com/standards/#private-submodules *)modulePrivate:sigvalleap_year_table:intarrayvalnon_leap_year_table:intarrayvalordinal_date:t->intendend