package orsetto
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=151ca6df499bd3de7aa89a4e1627411fbee24c4dea6e0e71ce21f06f181ee654
md5=00393728b481c2bf15919a8202732335
doc/orsetto.cf/Cf_gregorian/index.html
Module Cf_gregorian
Civil dates in the proleptic Gregorian calendar.
Overview
This module implements a record type inhabited by proleptic Gregorian calendar dates. It also provides related functions and types to facilitate conversion to and from various formats for data interchange.
Days, weeks, and months are numbered according to ISO 8601. Days of the month are represented by integers from 1 to 31. Months of the year are represented by integers from 1 to 12. Days of the week are represented by integers from 1 to 7, where 1 is Monday and 7 is Sunday. Days of the year are numbered from 1 to 366, where only leap years contain day number 366. Weeks of the year are numbered from 1 to 53.
Additional, an ancillary private type is also provided here to facilitate conversions between a useful subset of dates and their corresponding Chronological Julian Day (CJD) numbers. These functions are useful for adjustments of dates by intervals measured in integral numbers of days. The first Chronological Julian Day, numbered zero, was 24 Nov 4714 BCE.
Types
The private type inhabited by dates in a useful subset of the proleptic Gregorian calendar.
The type inhabited by Chronological Julian Day numbers, which correspond to a useful subset of dates in the Gregorian calendar, including those dates that are accepted by the Internet time stamp format (RFC 3339).
Functions
val create : year:int64 -> month:int -> day:int -> dateUse create ~year ~month ~day to create a date according to the values of ~year, ~month and ~day. Raises Invalid_argument if the month or day values are not valid for year in the proleptic Gregorian calendar.
Using is_valid ~year ~month ~day returns true if year, month and day arguments specify a valid proleptic Gregorian date.
val day_of_week : date -> intUse day_of_week d to compute the day of the week on which d occurs. Days of the week are numbered according to ISO 8601, i.e. from 1 to 7, starting on Monday and ending on Sunday.
val day_of_year : date -> intUse day_of_year day to compute the ordinal day of the year on which d occurs according to ISO 8601, i.e. from 1 to 366.
val week_number : date -> int64 * intUse week_number d to compute the year and week number in which d occurs. Weeks are numbered according to ISO 8601, i.e. from 1 to 53.
to_cjd d computes the Chronological Julian Day number for d.
Gregorian dates between 12 Aug 2937947 BCE and 27 Feb 2935093 CE inclusive are convertible to Chronological Julian Day numbers on platforms where the Ocaml integer is a 31-bit integer. Accordingly, Failure is raised if the Chronological Julian Day corresponding to the date is outside the range that can be represented with an integer.
val in_cjd_range : date -> boolUsing is_cjd_range d returns true if d is within the range of dates that can be represented by a Chronological Julian Day (CJD) number.