Module Date.Period
A period is the number of days between two dates.
Arithmetic operations
type +'a p
constraint 'a = [< field ]
include Period.S with type +'a period = 'a p
type +'a period
= 'a p
type t
= Period.date_field period
Type of a period.
Period is an additive monoid
val empty : 'a period
The empty period.
Periods are comparable
val equal : 'a period -> 'b period -> bool
Equality function between two periods.
- see Utils.Comparable.html#VALequal
Utils.Comparable.equal
- since
- 1.09.0
val compare : 'a period -> 'b period -> int
Comparison function between two periods.
- see Utils.Comparable.html#VALcompare
Utils.Comparable.compare
val hash : 'a period -> int
Hash function for periods.
- see Utils.Comparable.html#VALhash
Utils.Comparable.hash
- since
- 2.0
Constructors
val make : int -> int -> int -> t
make year month day
makes a period of the specified length.
val lmake : ?year:int -> ?month:int -> ?day:int -> unit -> t
Labelled version of
make
. The default value of each argument is0
.
val year : int -> [> `Year ] period
year n
makes a period ofn
years.
val month : int -> [> `Year | `Month ] period
month n
makes a period ofn
months.
val week : int -> [> `Week | `Day ] period
week n
makes a period ofn
weeks.
val day : int -> [> `Week | `Day ] period
day n
makes a period ofn
days.
Getters
val nb_days : 'a period -> int
val safe_nb_days : [< `Week | `Day ] period -> int
Equivalent to
nb_days
but never raises any exception.- since
- 2.02
val ymd : 'a period -> int * int * int