Module Fcalendar.Precise

module Precise: Calendar_sig.S  with module Date = Date and module Time = Ftime
More precise implementation of calendar in which seconds are float.
Since 2.0


Datatypes


module Date: Date_sig.S 
Date implementation used by this calendar.
module Time: Time_sig.S 
Time implementation used by this calendar.
type t 
type day = Date.day = 
| Sun
| Mon
| Tue
| Wed
| Thu
| Fri
| Sat (*
Days of the week.
*)
type month = Date.month = 
| Jan
| Feb
| Mar
| Apr
| May
| Jun
| Jul
| Aug
| Sep
| Oct
| Nov
| Dec (*
Months of the year.
*)
type year = Date.year 
Year as an int
type second = Time.second 
type field = [ `Day | `Hour | `Minute | `Month | `Second | `Week | `Year ] 
The different fields of a calendar.

Constructors


val make : int -> int -> int -> int -> int -> second -> t
make year month day hour minute second makes the calendar "year-month-day; hour-minute-second".
Raises
val lmake : year:int ->
?month:int ->
?day:int ->
?hour:int ->
?minute:int -> ?second:second -> unit -> t
Labelled version of make. The default value of month and day (resp. of hour, minute and second) is 1 (resp. 0).
Since 1.05
Raises
val create : Date.t -> Time.t -> t
create d t creates a calendar from the given date and time.
val now : unit -> t
now () returns the current date and time (in the current time zone).
val from_jd : float -> t
Return the Julian day. More precise than Date.from_jd: the fractional part represents the time.
val from_mjd : float -> t
Return the Modified Julian day. It is Julian day - 2 400 000.5 (more precise than Date.from_mjd).

Conversions



Conversions



Those functions have the same behaviour as those defined in Time_sig.S.
val convert : t -> Time_Zone.t -> Time_Zone.t -> t
See also Time_sig.S.convert
val to_gmt : t -> t
See also Time_sig.S.to_gmt
val from_gmt : t -> t
See also Time_sig.S.from_gmt

Getters



Getters



Those functions have the same behavious as those defined in Date_sig.S.
val days_in_month : t -> int
See also Date_sig.S.days_in_month
val day_of_week : t -> day
See also Date_sig.S.days_of_week
val day_of_month : t -> int
See also Date_sig.S.days_of_month
val day_of_year : t -> int
See also Date_sig.S.days_of_year
val week : t -> int
See also Date_sig.S.week
val month : t -> month
See also Date_sig.S.month
val year : t -> int
See also Date_sig.S.year

to_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 -> float

Those functions have the same behavious as those defined in Time_sig.S.
val hour : t -> int
See also Time_sig.S.hour
val minute : t -> int
See also Time_sig.S.minute
val second : t -> second
See also Time_sig.S.second

Calendars are comparable


val equal : t -> t -> bool
Equality function between two calendars.
See also Utils.Comparable.equal.
val compare : t -> t -> int
Comparison function between two calendars.
See also Utils.Comparable.compare.
val hash : t -> int
Hash function for calendars.
Since 2.0
See also Utils.Comparable.hash.

Those functions have the same behavious as those defined in Date_sig.S.
val is_leap_day : t -> bool
See also Date_sig.S.is_leap_day
val is_gregorian : t -> bool
See also Date_sig.S.is_gregorian
val is_julian : t -> bool
See also Date_sig.S.is_julian

Those functions have the same behavious as those defined in Time_sig.S.
val is_pm : t -> bool
See also Time_sig.S.is_pm
val is_am : t -> bool
See also Time_sig.S.is_am

Coercions


val to_unixtm : t -> Unix.tm
Convert a calendar into the unix.tm type. The field isdst is always false. More precise than Date_sig.S.to_unixtm.
Since 1.01
val from_unixtm : Unix.tm -> t
Inverse of to_unixtm. Assumes the current time zone. So, The following invariant holds: hour (from_unixtm u) = u.Unix.tm_hour.
Since 1.01
val to_unixfloat : t -> float
Convert 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.
Since 1.01
val from_unixfloat : float -> t
Inverse of to_unixfloat. Assumes the current time zone. So, the following invariant holds: hour (from_unixfloat u) = (Unix.gmtime u).Unix.tm_hour.
Since 1.01
val from_date : Date.t -> t
Convert a date to a calendar. The time is midnight in the current time zone.
val to_date : t -> Date.t
Convert a calendar to a date. Time part of the calendar is ignored.
val to_time : t -> Time.t
Convert a calendar to a time. Date part of the calendar is ignored.
Since 1.03

Period


module Period: sig .. end
A period is the number of seconds between two calendars.

Arithmetic operations on calendars and periods



Arithmetic operations on calendars and periods



Those functions have the same behavious as those defined in Date_sig.S.
val add : t ->
[< Period.date_field ] Period.period -> t
See also Date_sig.S.add
val sub : t ->
t ->
[< Period.date_field > `Day `Week ] Period.period
See also Date_sig.S.sub
val precise_sub : t -> t -> Period.t
Since 2.03
See also Date_sig.S.precise_sub
val rem : t ->
[< Period.date_field ] Period.period -> t
See also Date_sig.S.rem
val next : t -> field -> t
See also Date_sig.S.next
val prev : t -> field -> t
See also Date_sig.S.prev