module Period:sig
..end
A period is the number of seconds between two calendars.
type +[< Period.date_field ]
period
typet =
Period.date_field period
Type of a period.
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.
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.
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
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.
to_date (hour 60)
is equivalent to Date.Period.days 2
.exception Not_computable
= Date.Period.Not_computable
.
val to_time : ([< Period.date_field ] as 'a) period ->
'a Time.Period.period
Calendar_sig.S.Period.safe_to_time
insteadConvert a calendar period to a date period.
Not_computable
if the time period is not computable.to_time (year 1)
raises Not_computable
because
a year is not a constant number of days.to_time (second 30)
returns a time period of 30
secondsto_time (day 6)
returns a time period of 24 * 3600 * 6 =
518400
secondsval 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.
ymds (make (-1) (-2) (-3) (-1) (-2) (-3)
returns
-1, -2, -4, 82677
.ymds (make 1 2 3 1 2 3)
returns 1, 2, 3, 3723