github ↗
docs menu

Module Time.Date

Dates.

#type t = date

The type for dates.

#val of_civil : (int * int * int) -> date option

of_civil (y, m, d) is day d of month m of year y in the proleptic Gregorian calendar, or None if m is not in [1;12], d is not a day of that month, or the date is out of range. Years are astronomical: year 0 is 1 BC and year -1 is 2 BC.

#val to_civil : date -> int * int * int

to_civil t is (y, m, d), the year, month and day of t. of_civil (to_civil t) is Some t.

#val of_days : int -> date option

of_days n is the date n days after 1970-01-01, or None if it is out of range.

#val to_days : date -> int

to_days t is the number of days from 1970-01-01 to t.

#val equal : date -> date -> bool

equal t0 t1 is true iff t0 and t1 are the same day.

#val compare : date -> date -> int

compare t0 t1 orders dates chronologically. It is compatible with equal.

#val pp : Stdlib.Format.formatter -> date -> unit

pp ppf t formats t as YYYY-MM-DD. A year outside [0;9999] is signed and has at least four digits: -0044-03-15, +12345-01-01.