Module Betacalendars.Civil_date

type t

Valid proleptic Gregorian dates, independent of timestamps and time zones.

type error =
  1. | Invalid_year of int
  2. | Invalid_month of int
  3. | Invalid_day of {
    1. year : int;
    2. month : int;
    3. day : int;
    }
val make : year:int -> month:int -> day:int -> (t, error) Stdlib.result

Construct a valid Gregorian date in years 1 through 9999.

val year : t -> int

Return the year component.

val month : t -> int

Return the month component from 1 through 12.

val day : t -> int

Return the day component.

val equal : t -> t -> bool

Test structural date equality.

val compare : t -> t -> int

Compare dates chronologically.

val is_leap_year : int -> bool

Gregorian leap-year predicate. Input is not otherwise range-limited.

val days_in_month : year:int -> month:int -> int

Number of days in a valid Gregorian month; returns zero for invalid months.

val day_of_year : t -> int

Return the one-based ordinal day within the year.

val weekday : t -> Weekday.t

Return the ISO weekday with Monday first.

val add_days : t -> int -> t option

Add signed days; return None if the result leaves years 1 through 9999.

val diff_days : t -> t -> int

Signed day distance from a to b.

val to_string : t -> string

Canonical zero-padded YYYY-MM-DD form.