Module Calendar_sig.S.Period

module Period: sig .. end

A period is the number of seconds between two calendars.


Arithmetic operations

type +[< Period.date_field ] period 
type t = Period.date_field period 

Type of a period.

Period is an additive monoid

val empty : [< Period.date_field ] period

The empty period.

val add : ([< Period.date_field > `Day `Week ] as 'a) period ->
'a period -> 'a period

Addition of periods.

val sub : ([< Period.date_field > `Day `Week ] as 'a) period ->
'a period -> 'a period

Substraction of periods.

val opp : ([< Period.date_field > `Day `Week ] as 'a) period ->
'a period

Opposite of a period.

Periods are comparable

val equal : [< Period.date_field ] period ->
[< Period.date_field ] period -> bool

Equality function between two periods.

val compare : [< Period.date_field ] period ->
[< Period.date_field ] period -> int

Comparison function between two periods.

val hash : [< Period.date_field ] period -> int

Hash function for periods.

Constructors

val make : int ->
int -> int -> int -> int -> Calendar_sig.S.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:Calendar_sig.S.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 -> [< Period.date_field > `Year ] period
val month : int -> [< Period.date_field > `Month `Year ] period
val week : int -> [< Period.date_field > `Day `Week ] period
val day : int -> [< Period.date_field > `Day `Week ] period

Those functions have the same behavious as those defined in .

val hour : int -> [< Period.date_field > `Day `Week ] period
val minute : int -> [< Period.date_field > `Day `Week ] period
val second : Calendar_sig.S.second ->
[< Period.date_field > `Day `Week ] period

Coercions

val from_date : ([< Period.date_field ] as 'a) Date.Period.period ->
'a period

Convert a date period to a calendar period.

val from_time : ([< Period.date_field ] as 'a) Time.Period.period ->
'a period

Convert a time period to a calendar period.

val to_date : ([< Date.field ] as 'a) period -> 'a Date.Period.period

Convert a calendar period to a date period. The fractional time period is ignored.

exception Not_computable

Date.Period.Not_computable.

val to_time : ([< Period.date_field ] as 'a) period ->
'a Time.Period.period
Deprecated.since 2.02: use Calendar_sig.S.Period.safe_to_time instead

Convert a calendar period to a date period.

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

Equivalent to Calendar_sig.S.Period.to_time but never raises any exception.

val ymds : [< Period.date_field ] period ->
int * int * int * Calendar_sig.S.second

Number of years, months, days and seconds in a period.