package dates_calc

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

A valid date in the standard Gregorian calendar.

type period

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

exception InvalidDate
exception AmbiguousComputation
type date_rounding =
  1. | RoundUp
  2. | RoundDown
  3. | AbortOnRound
    (*

    When choosing AbortOnRound, functions may raise AmbiguousComputation.

    *)

Functions on dates

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

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

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

Respects ISO8601 format.

Functions on periods

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

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

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

Innovation. Community. Security.