module Period: sig
.. end
A period is the number of seconds between two calendars.
Arithmetic operations
include Period.S
Constructors
val make : int -> int -> int -> int -> int -> int -> Calendar.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:int -> unit -> Calendar.t
Labelled version of make
.
The default value of each argument is 0
.
Those functions have the same behavious as those defined in Date
.
val year : int -> Calendar.t
val month : int -> Calendar.t
val week : int -> Calendar.t
val day : int -> Calendar.t
Those functions have the same behavious as those defined in Time
.
val hour : int -> Calendar.t
val minute : int -> Calendar.t
val second : int -> Calendar.t
Coercions
val from_date : Date.Period.t -> Calendar.t
Convert a date period to a calendar period.
val from_time : Time.Period.t -> Calendar.t
Convert a time period to a calendar period.
val to_date : Calendar.t -> Date.Period.t
Convert a calendar period to a date period.
The fractional time period is ignored.
E.g. to_date (hour 60)
is equivalent to Date.Period.days 2
.
exception Not_computable
= Date.Period.Not_computable
.
Since 1.04
val to_time : Calendar.t -> Time.Period.t
Convert a calendar period to a date period.
Throw Not_computable
if the time period is not computable.
E.g. to_time (day 6)
and to_time (second 30)
respectively return a
time period of 24 * 3600 * 6 = 518400
seconds and a time period of 30
seconds but to_time (year 1)
throws Not_computable
because a year is
not a constant number of days.
Since 1.04
val ymds : Calendar.t -> int * int * int * int
Number of years, months, days and seconds in a period.
E.g. ymds (make 1 2 3 1 2 3)
returns 1, 2, 3, 3723
and
ymds (make (-1) (-2) (-3) (-1) (-2) (-3)
returns
-1, -2, -4, 82677
.
Since 1.09.0