Up

Module Date = Date0

Signature

type t
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val __bin_read_t__ : (int -> t) Core_kernel.Std.Bin_prot.Read.reader
include Core_kernel.Std.Hashable_binable with type t := t
type t
val hash : t -> int
module Table : Hashable.Hashtbl.S_binable with type key = t
include Core_kernel.Std.Stringable with type t := t
type t
val of_string : string -> t
val to_string : t -> string
include Core_kernel.Std.Comparable_binable with type t := t
include Comparable_intf.S_common
include Comparable_intf.Polymorphic_compare
include Polymorphic_compare_intf.Infix
type 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

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 Or_error.t
include Comparator.S with type t := t
type t
type comparator_witness
include Comparable_intf.Validate with type t := t
type t
val validate_lbound : min:t Maybe_bound.t -> t Validate.check
val validate_ubound : max:t Maybe_bound.t -> t Validate.check
val validate_bound : min:t Maybe_bound.t -> max:t Maybe_bound.t -> t Validate.check
include Comparable_intf.Map_and_set_binable with type t := t with type comparator_witness := comparator_witness
type t
include Comparator.S with type t := t
type t
type comparator_witness
include Core_kernel.Std.Pretty_printer.S with type t := t
type t
val pp : Format.formatter -> t -> unit
val create_exn : y:int -> m:Core_kernel.Std.Month.t -> d:int -> 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_tm : Core_unix.tm -> t
val of_string_iso8601_basic : string -> pos:int -> t
val to_string_iso8601_basic : t -> string
val to_string_american : t -> string
val day : t -> int
val month : t -> Core_kernel.Std.Month.t
val year : t -> int
val day_of_week : t -> Core_kernel.Std.Day_of_week.t
val week_number : t -> int

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 -> bool
val is_weekday : t -> bool
val is_business_day : t -> is_holiday:(t -> bool) -> bool

Monday through Friday are business days, unless they're a holiday. Use Pnl_db.Holidays.is_holiday as a convenient holiday function.

val add_days : t -> int -> t
val add_months : 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. *

val diff : t -> t -> int
ERROR: date0.mli:67:4-67:5
2:4-2:5 :
unterminated '['
val diff_weekdays : t -> t -> int
ERROR: date0.mli:67:4-67:5
2:4-2:5 :
unterminated '['
val diff_weekend_days : t -> t -> int
ERROR: date0.mli:70:23-70:24
2:23-2:24 :
unterminated '['
val add_weekdays : t -> 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.

val add_business_days : t -> is_holiday:(t -> bool) -> int -> 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. Use Pnl_db.Holidays.is_holiday as a convenient holiday function.

val dates_between : min:t -> max:t -> t list
val business_dates_between : min:t -> max:t -> is_holiday:(t -> bool) -> t list
val weekdays_between : min:t -> max:t -> t list
val previous_weekday : t -> t
val following_weekday : t -> t
val first_strictly_after : t -> on:Core_kernel.Std.Day_of_week.t -> t

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

module Stable : sig .. end
module O : sig .. end