#### Arithmetic operations

`type +'a period constraint 'a = [< Period.date_field ]`
`type t = Period.date_field period`

Type of a period.

#### Period is an additive monoid

`val empty : 'a period`

The empty period.

`val add : ([> `Day | `Week ] as 'a) period -> 'a period -> 'a period`

Addition of periods.

`val sub : ([> `Day | `Week ] as 'a) period -> 'a period -> 'a period`

Substraction of periods.

`val opp : ([> `Day | `Week ] as 'a) period -> 'a period`

Opposite of a 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 -> int -> int -> second -> t`

`make year month day hour minute second` makes a period of the specified length.

`val lmake : ?year:int -> ?month:int -> ?day:int -> ?hour:int -> ?minute:int -> ?second:second -> unit -> t`

Labelled version of `make`. The default value of each argument is `0`.

Those functions have the same behavious as those defined in `Date_sig.S.Period`.

`val year : int -> [> `Year ] period`

- see Date_sig.S.Period.html#VALyear

  Date_sig.S.Period.year

`val month : int -> [> `Year | `Month ] period`

- see Date_sig.S.Period.html#VALmonth

  Date_sig.S.Period.month

`val week : int -> [> `Week | `Day ] period`

- see Date_sig.S.Period.html#VALweek

  Date_sig.S.Period.week

`val day : int -> [> `Week | `Day ] period`

- see Date_sig.S.Period.html#VALday

  Date_sig.S.Period.day

Those functions have the same behavious as those defined in `Time_sig.S.Period`.

`val hour : int -> [> `Week | `Day ] period`

- see Time_sig.S.Period.html#VALhour

  Time_sig.S.Period.hour

`val minute : int -> [> `Week | `Day ] period`

- see Time_sig.S.Period.html#VALminute

  Time_sig.S.Period.minute

`val second : second -> [> `Week | `Day ] period`

- see Time_sig.S.Period.html#VALsecond

  Time_sig.S.Period.second

#### Coercions

`val from_date : 'a Date.Period.period -> 'a period`

Convert a date period to a calendar period.

`val from_time : 'a Time.Period.period -> 'a period`

Convert a time period to a calendar period.

`val to_date : 'a period -> 'a Date.Period.period`

Convert a calendar period to a date period. The fractional time period is ignored. @example `to_date (hour 60)` is equivalent to `Date.Period.days 2`.

`exception Not_computable`

`= Date.Period.Not_computable`.

- since 1.04

`val to_time : 'a period -> 'a Time.Period.period`

Convert a calendar period to a date period.

- raises `Not_computable`

  if the time period is not computable. @example `to_time (day 6)` returns a time period of `24 * 3600 * 6 = 518400` seconds @example `to_time (second 30)` returns a time period of `30` seconds @example `to_time (year 1)` raises `Not_computable` because a year is not a constant number of days.

- since 1.04

- deprecated

  since 2.02: use `safe_to_time` instead

`val safe_to_time : ([< `Week | `Day ] as 'a) period -> 'a Time.Period.period`

Equivalent to `to_time` but never raises any exception.

- since 2.02

`val ymds : 'a period -> int * int * int * second`

Number of years, months, days and seconds in a period. @example `ymds (make 1 2 3 1 2 3)` returns `1, 2, 3, 3723` @example `ymds (make (-1) (-2) (-3) (-1) (-2) (-3)` returns `-1, -2, -4, 82677`.

- since 1.09.0