module Calendar:Calendar operations.sig..end
This module combines the implementations on Date and Time.
So, a calendar is a 6-uple (year, month, day, hour, minute, second).
If you only need operations on dates, you should better use the module
Date. But if you need to manage more precise date, use this module.
The exact Julian period is now
[January, 1st 4713 BC at midday GMT; January 22th, 3268 AC at midday GMT].
This module uses floating point arithmetics.
Then, egality over calendars may be erroneous (as egality over float).
You should better use the equal function defined in this module instead
of (=).
type t
typeday =Date.day=
| |
Sun |
|||
| |
Mon |
|||
| |
Tue |
|||
| |
Wed |
|||
| |
Thu |
|||
| |
Fri |
|||
| |
Sat |
(* | Days of the week. | *) |
typemonth =Date.month=
| |
Jan |
|||
| |
Feb |
|||
| |
Mar |
|||
| |
Apr |
|||
| |
May |
|||
| |
Jun |
|||
| |
Jul |
|||
| |
Aug |
|||
| |
Sep |
|||
| |
Oct |
|||
| |
Nov |
|||
| |
Dec |
(* | Months of the year. | *) |
typeyear =Date.year
typefield =[ `Day | `Hour | `Minute | `Month | `Second | `Week | `Year ]
val make : int -> int -> int -> int -> int -> int -> tmake year month day hour minute second makes the calendar
"year-month-day; hour-minute-second".val lmake : year:int ->
?month:int ->
?day:int -> ?hour:int -> ?minute:int -> ?second:int -> unit -> tmake.
The default value of month and day (resp. of hour, minute
and second) is 1 (resp. 0).val create : Date.t -> Time.t -> tcreate d t creates a calendar from the given date and time.val now : unit -> tnow () returns the current date and time (in the current time zone).val from_jd : float -> tDate.from_jd: the fractional part represents the
time.val from_mjd : float -> tJulian day - 2 400 000.5 (more precise than Date.from_mjd).Time.val convert : t -> Time_Zone.t -> Time_Zone.t -> tval to_gmt : t -> tval from_gmt : t -> tDate.val days_in_month : t -> intval day_of_week : t -> dayval day_of_month : t -> intval day_of_year : t -> intval week : t -> intval month : t -> monthval year : t -> intto_jd and to_mjd are more precise than Date.to_jd and
Date.to_mjd.val to_jd : t -> floatval to_mjd : t -> floatTime.val hour : t -> intval minute : t -> intval second : t -> intval equal : t -> t -> boolequal should be used instead of (=).Date.val compare : t -> t -> intval is_leap_day : t -> boolval is_gregorian : t -> boolval is_julian : t -> boolTime.val is_pm : t -> boolval is_am : t -> boolval to_unixtm : t -> Unix.tmunix.tm type.
The field isdst is always false. More precise than Date.to_unixtm.val from_unixtm : Unix.tm -> tto_unixtm. Assumes the current time zone.
So, we have the following invariant:
hour (from_unixtm u) = u.Unix.tm_hour.val to_unixfloat : t -> floatto_unixfloat (make 1970 1 1 0 0 0) returns 0.0 at UTC.
So such a float is convertible with those of the Unix module.
More precise than Date.to_unixfloat.val from_unixfloat : float -> tto_unixfloat. Assumes the current time zone.
So, we have the following invariant:
hour (from_unixfloat u) = (Unix.gmtime u).Unix.tm_hour.val from_date : Date.t -> tval to_date : t -> Date.tval to_time : t -> Time.tmodule Period:sig..end
Date.val add : t -> Period.t -> tval sub : t -> t -> Period.tval rem : t -> Period.t -> tval next : t -> field -> tval prev : t -> field -> t