module Make_Precise:
Similar to Calendar_builder.Make but results are more precise. The counterpart is that
some operations are less efficient.
| Parameters: |
|
module Date:Date_sig.S
Date implementation used by this calendar.
module Time:Time_sig.S
Time implementation used by this calendar.
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
Year as an int
typesecond =Time.second
typefield =[ `Day | `Hour | `Minute | `Month | `Second | `Week | `Year ]
The different fields of a calendar.
val make : int -> int -> int -> int -> int -> second -> tmake year month day hour minute second makes the calendar
"year-month-day; hour-minute-second".
D.Out_of_bounds when a date is outside the Julian period.D.Undefined when a date belongs to [October 5th, 1582; October
14th, 1582].val lmake : year:int ->
?month:int ->
?day:int ->
?hour:int ->
?minute:int -> ?second:second -> unit -> tLabelled version of make.
The default value of month and day (resp. of hour, minute
and second) is 1 (resp. 0).
D.Out_of_bounds when a date is outside the Julian period.D.Undefined when a date belongs to [October 5th, 1582; October
14th, 1582].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 -> tReturn the Julian day.
More precise than Date.from_jd: the fractional part represents the
time.
val from_mjd : float -> tReturn the Modified Julian day.
It is Julian day - 2 400 000.5 (more precise than Date.from_mjd).
Those functions have the same behaviour as those defined in
Time_sig.S.
val convert : t -> Time_Zone.t -> Time_Zone.t -> tval to_gmt : t -> tval from_gmt : t -> tThose functions have the same behavious as those defined in
Date_sig.S.
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_sig.S.to_jd and
Date_sig.S.to_mjd.
val to_jd : t -> float
val to_mjd : t -> floatThose functions have the same behavious as those defined in
Time_sig.S.
val hour : t -> intval minute : t -> intval second : t -> secondval equal : t -> t -> boolEquality function between two calendars.
val compare : t -> t -> intComparison function between two calendars.
val hash : t -> intHash function for calendars.
Those functions have the same behavious as those defined in
Date_sig.S.
val is_leap_day : t -> boolval is_gregorian : t -> boolval is_julian : t -> boolThose functions have the same behavious as those defined in
Time_sig.S.
val is_pm : t -> boolval is_am : t -> boolval to_unixtm : t -> Unix.tmConvert a calendar into the unix.tm type.
The field isdst is always false. More precise than
Date_sig.S.to_unixtm.
val from_unixtm : Unix.tm -> tInverse of to_unixtm. Assumes the current time zone.
So, The following invariant holds:
hour (from_unixtm u) = u.Unix.tm_hour.
val to_unixfloat : t -> floatConvert a calendar to a float such than
to_unixfloat (make 1970 1 1 0 0 0) returns 0.0 at UTC.
So such a float is convertible with those of the module Unix.
More precise than Date_sig.S.to_unixfloat.
val from_unixfloat : float -> tInverse of to_unixfloat. Assumes the current time zone.
So, the following invariant holds:
hour (from_unixfloat u) = (Unix.gmtime u).Unix.tm_hour.
val from_date : Date.t -> tConvert a date to a calendar. The time is midnight in the current time zone.
val to_date : t -> Date.tConvert a calendar to a date. Time part of the calendar is ignored.
val to_time : t -> Time.tConvert a calendar to a time. Date part of the calendar is ignored.
module Period:sig..end
A period is the number of seconds between two calendars.
Those functions have the same behavious as those defined in
Date_sig.S.
val add : t ->
[< Period.date_field ] Period.period -> tval sub : t ->
t ->
[< Period.date_field > `Day `Week ] Period.periodval precise_sub : t -> t -> Period.tval rem : t ->
[< Period.date_field ] Period.period -> tval next : t -> field -> tval prev : t -> field -> t