package dates_calc

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Dates_calc.DatesSource

Sourcetype date

A valid date in the standard Gregorian calendar.

Sourcetype period

A period can be any number and combination of days, months, years.

Sourceexception InvalidDate
Sourceexception AmbiguousComputation
Sourcetype date_rounding =
  1. | RoundUp
  2. | RoundDown
  3. | AbortOnRound
    (*

    When choosing AbortOnRound, functions may raise AmbiguousComputation.

    *)

Functions on dates

Sourceval make_date : year:int -> month:int -> day:int -> date
  • raises [InvalidDate]
Sourceval add_dates : ?round:date_rounding -> date -> period -> date
  • raises [AmbiguousComputation]
Sourceval sub_dates : date -> date -> period

The returned period is always expressed as a number of days.

Sourceval compare_dates : date -> date -> int
Sourceval date_to_ymd : date -> int * int * int
Sourceval format_date : Format.formatter -> date -> unit

Respects ISO8601 format.

Sourceval date_of_string : string -> date
Sourceval first_day_of_month : date -> date
Sourceval last_day_of_month : date -> date
Sourceval is_leap_year : int -> bool

Functions on periods

Sourceval make_period : years:int -> months:int -> days:int -> period
Sourceval neg_period : period -> period
Sourceval add_periods : period -> period -> period
Sourceval sub_periods : period -> period -> period
Sourceval mul_period : period -> int -> period
Sourceval format_period : Format.formatter -> period -> unit
Sourceval period_of_string : string -> period
Sourceval period_to_days : period -> int
  • raises [AmbiguousComputation]

    when the period is anything else than a number of days.

Sourceval period_to_ymds : period -> int * int * int
OCaml

Innovation. Community. Security.