module type S =Common operations for all date representations.sig
..end
type
t
type
day =
| |
Sun |
| |
Mon |
| |
Tue |
| |
Wed |
| |
Thu |
| |
Fri |
| |
Sat |
type
month =
| |
Jan |
| |
Feb |
| |
Mar |
| |
Apr |
| |
May |
| |
Jun |
| |
Jul |
| |
Aug |
| |
Sep |
| |
Oct |
| |
Nov |
| |
Dec |
typeyear =
int
int
.typefield =
[ `Day | `Month | `Week | `Year ]
exception Out_of_bounds
exception Undefined
[October 5th, 1582; October 14th, 1582]
.val make : year -> int -> int -> t
make year month day
makes the date year-month-day. A BC year y
corresponds to the year -(y+1)
.Out_of_bounds
when a date is outside the Julian period.Undefined
when a date belongs to [October 5th, 1582; October
14th, 1582]
.val lmake : year:year -> ?month:int -> ?day:int -> unit -> t
make
.
The default value of month
and day
is 1
.Out_of_bounds
when a date is outside the Julian period.Undefined
when a date belongs to [October 5th, 1582; October
14th, 1582]
.val today : unit -> t
Time_Zone.current ()
).val from_jd : int -> t
val from_mjd : int -> t
val from_day_of_year : year -> int -> t
val days_in_month : t -> int
val day_of_week : t -> day
val day_of_month : t -> int
val day_of_year : t -> int
val week : t -> int
val month : t -> month
val year : t -> year
val to_jd : t -> int
val to_mjd : t -> int
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
val is_valid_date : year -> int -> int -> bool
val is_leap_day : t -> bool
true
if a date is a leap day
(i.e. February, 24th of a leap year); false
otherwise.val is_gregorian : t -> bool
true
if a date belongs to the Gregorian calendar;
false
otherwise.val is_julian : t -> bool
true
iff a date belongs to the Julian calendar;
false
otherwise.val to_unixtm : t -> Unix.tm
Unix.tm
type.
The field is_isdst
is always false
. The fields Unix.tm_sec
,
Unix.tm_min
and Unix.tm_hour
are irrelevant.val from_unixtm : Unix.tm -> t
to_unixtm
. Assume the current time zone.val to_unixfloat : t -> float
to_unixfloat (make 1970 1 1)
returns 0.0
. So such a float is convertible with those of the Unix
module. The fractional part of the result is always 0
.val from_unixfloat : float -> t
to_unixfloat
. Ignore the fractional part of the argument.
Assume the current time zone.val to_business : t -> year * int * day
val from_business : year -> int -> day -> t
to_business
respecting ISO-8601.
Notice that business weeks at the beginning and end of the year
can sometimes have year numbers which don't match the real year.Invalid_argument
if the date is bad.val int_of_day : day -> int
val day_of_int : int -> day
int_of_day
.Invalid_argument
if the argument does not belong to 1; 7
.val int_of_month : month -> int
val month_of_int : int -> month
int_of_month
.Invalid_argument
if the argument does not belong to 1; 12
.module Period:sig
..end
val add : t -> Period.t -> t
add d p
returns d + p
.Out_of_bounds
when the resulting date is outside the Julian
period.Undefined
when the resulting date belongs to [October 5th,
1582; October 14th, 1582]
.val sub : t -> t -> Period.t
sub d1 d2
returns the period between d1
and d2
.val rem : t -> Period.t -> t
rem d p
is equivalent to add d (Period.opp p)
.Out_of_bounds
when the resulting date is outside the Julian
period.Undefined
when the resulting date belongs to [October 5th,
1582; October 14th, 1582]
.val next : t -> field -> t
next d f
returns the date corresponding to the next specified field.Out_of_bounds
when the resulting date is outside the Julian
period.Undefined
when the resulting date belongs to [October 5th,
1582; October 14th, 1582]
.val prev : t -> field -> t
prev d f
returns the date corresponding to the previous specified
field.Out_of_bounds
when the resulting date is outside the Julian
period.Undefined
when the resulting date belongs to [October 5th,
1582; October 14th, 1582]
.val is_leap_year : year -> bool
true
if a year is a leap year; false
otherwise.val same_calendar : year -> year -> bool
true
if two years have the same calendar; false
otherwise.val days_in_year : ?month:month -> year -> int
days_in_year ~month y
returns the number of days in the year y
up
to the end of the given month. Thus days_in_year ~month:Dec y
is the
same as days_in_year y
.
val weeks_in_year : year -> int
val week_first_last : int -> year -> t * t
val nth_weekday_of_month : year -> month -> day -> int -> t
nth_weekday_of_month y m d n
returns the n
-th day d
in the month
m
of the year y
(for instance the 3rd Thursday of the month).val century : year -> int
val millenium : year -> int
val solar_number : year -> int
In the Julian calendar there is a one-to-one relationship between the
Solar number and the day on which a particular date falls.
val indiction : year -> int
The Indiction was used in the middle ages to specify the position of a year in a 15 year taxation cycle. It was introduced by emperor Constantine the Great on 1 September 312 and ceased to be used in 1806.
The Indiction has no astronomical significance.
val golden_number : year -> int
Considering that the relationship between the moon's phases and the
days of the year repeats itself every 19 years, it is natural to
associate a number between 1 and 19 with each year.
This number is the so-called Golden number.
val epact : year -> int
The Epact is a measure of the age of the moon (i.e. the number of days
that have passed since an "official" new moon) on a particular date.
val easter : year -> t
In the Christian world, Easter (and the days immediately preceding it)
is the celebration of the death and resurrection of Jesus in
(approximately) AD 30.
val carnaval : year -> t
carnaval y
is easter y - 48
.val mardi_gras : year -> t
mardi_gras y
is easter y - 47
.val ash : year -> t
ash y
is easter y - 46
.val palm : year -> t
palm y
is easter y - 7
.val easter_friday : year -> t
easter_friday y
is easter y - 2
.val easter_saturday : year -> t
easter_saturday y
is easter y - 1
.val easter_monday : year -> t
easter_monday y
is easter y + 1
.val ascension : year -> t
ascension y
is easter y + 39
.val withsunday : year -> t
withsunday y
is easter y + 49
.val withmonday : year -> t
withmonday y
is easter y + 50
.val corpus_christi : year -> t
corpus_christi y
is easter + 60
.