package calendar

  1. Overview
  2. Docs

Module Calendar.PreciseSource

More precise implementation of calendar in which seconds are integer.

  • since 2.0

Datatypes

Sourcemodule Date = Date

Date implementation used by this calendar.

Sourcemodule Time = Time

Time implementation used by this calendar.

Sourcetype t
Sourcetype day = Date.day =
  1. | Sun
  2. | Mon
  3. | Tue
  4. | Wed
  5. | Thu
  6. | Fri
  7. | Sat
    (*

    Days of the week.

    *)
Sourcetype month = Date.month =
  1. | Jan
  2. | Feb
  3. | Mar
  4. | Apr
  5. | May
  6. | Jun
  7. | Jul
  8. | Aug
  9. | Sep
  10. | Oct
  11. | Nov
  12. | Dec
    (*

    Months of the year.

    *)
Sourcetype year = Date.year

Year as an int

Sourcetype second = Time.second
Sourcetype field = [
  1. | Date.field
  2. | Time.field
]

The different fields of a calendar.

Constructors

Sourceval 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 D.Out_of_bounds

    when a date is outside the Julian period.

  • raises D.Undefined

    when a date belongs to [October 5th, 1582; October 14th, 1582].

Sourceval 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).

  • raises D.Out_of_bounds

    when a date is outside the Julian period.

  • raises D.Undefined

    when a date belongs to [October 5th, 1582; October 14th, 1582].

  • since 1.05
Sourceval create : Date.t -> Time.t -> t

create d t creates a calendar from the given date and time.

Sourceval now : unit -> t

now () returns the current date and time (in the current time zone).

Sourceval from_jd : float -> t

Return the Julian day. More precise than Date.from_jd: the fractional part represents the time.

Sourceval from_mjd : float -> t

Return the Modified Julian day. It is Julian day - 2 400 000.5 (more precise than Date.from_mjd).

Conversions

Those functions have the same behaviour as those defined in Time_sig.S.

Sourceval convert : t -> Time_Zone.t -> Time_Zone.t -> t
Sourceval to_gmt : t -> t
Sourceval from_gmt : t -> t

Getters

Those functions have the same behavious as those defined in Date_sig.S.

Sourceval days_in_month : t -> int
Sourceval day_of_week : t -> day
Sourceval day_of_month : t -> int
Sourceval day_of_year : t -> int
Sourceval week : t -> int
Sourceval month : t -> month
Sourceval year : t -> int

to_jd and to_mjd are more precise than Date_sig.S.to_jd and Date_sig.S.to_mjd.

Sourceval to_jd : t -> float
Sourceval to_mjd : t -> float

Those functions have the same behavious as those defined in Time_sig.S.

Sourceval hour : t -> int
Sourceval minute : t -> int
Sourceval second : t -> second

Calendars are comparable

Sourceval equal : t -> t -> bool

Equality function between two calendars.

Sourceval compare : t -> t -> int

Comparison function between two calendars.

Sourceval hash : t -> int

Hash function for calendars.

  • since 2.0

Those functions have the same behavious as those defined in Date_sig.S.

Sourceval is_leap_day : t -> bool
Sourceval is_gregorian : t -> bool
Sourceval is_julian : t -> bool

Those functions have the same behavious as those defined in Time_sig.S.

Sourceval is_pm : t -> bool
Sourceval is_am : t -> bool

Coercions

Sourceval 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
Sourceval 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
Sourceval 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
Sourceval 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
Sourceval from_date : Date.t -> t

Convert a date to a calendar. The time is midnight in the current time zone.

Sourceval to_date : t -> Date.t

Convert a calendar to a date. Time part of the calendar is ignored.

Sourceval to_time : t -> Time.t

Convert a calendar to a time. Date part of the calendar is ignored.

  • since 1.03

Period

Sourcemodule Period : sig ... end

A period is the number of seconds between two calendars.

Arithmetic operations on calendars and periods

Those functions have the same behavious as those defined in Date_sig.S.

Sourceval add : t -> 'a Period.period -> t
Sourceval sub : t -> t -> [> `Week | `Day ] Period.period
Sourceval precise_sub : t -> t -> Period.t
  • since 2.03
Sourceval rem : t -> 'a Period.period -> t
Sourceval next : t -> field -> t
Sourceval prev : t -> field -> t