package lunar

  1. Overview
  2. Docs

doc/lunar/Lunar/Era/index.html

Module Lunar.EraSource

Era identifies the historical period relative to year numbering. In the Gregorian/ISO calendar there are two eras: BCE and CE. Since Lunar just support dates between the years 0000 (in an astronomic sense), BCE is probably never used.

Types

Sourcetype t =
  1. | BCE
    (*

    Before Common Era

    *)
  2. | CE
    (*

    Common Era

    *)

The type describing an era.

Computing Era

Sourceval from_year : int -> t

from_year y compute the era for the given year y.

Relativizing from era

Sourceval year : int -> int

year y relativize the given year y from the associated era. It counts years within the era

Sourceval century : int -> int

century year returns the century inside the associated era.

Sourceval year_of_century : int -> int

year_of_century year returns the year position within the century inside the associated era.

Conversion

Sourceval to_string : t -> string

to_string era returns a string representation of the given era.

Sourceval to_int : t -> int

to_int era converts an era into a string 1 for CE and 0 for BCE.

Comparison

Sourceval equal : t -> t -> bool

Equality between eras.

Sourceval compare : t -> t -> int

compare a b comparison between eras, following OCaml convention.

val min : t -> t -> t

min a b returns the smaller of two arguments.

val max : t -> t -> t

max a b returns the greater of two arguments.

val clamp : min:t -> max:t -> t -> t

clamp ~min ~max x restricts the x to the inclusive interval [min, max].

val is_earlier : than:t -> t -> bool

is_earlier ~than x returns true if x is (strictly) earlier than than, false otherwise.

val is_later : than:t -> t -> bool

is_later ~than x returns true if x is (strictly) later than than, false otherwise.

Map and Set

Sourcemodule Map : Map.S with type key = t
Sourcemodule Set : Set.S with type elt = t

Infix operators

Sourcemodule Infix : sig ... end

Common and useful infix operators.

include module type of Infix
val (=) : t -> t -> bool

v1 = v2 is equal v1 v2.

val (<>) : t -> t -> bool

v1 <> v2 is not (equal v1 v2).

val (>) : t -> t -> bool

v1 > v2 returns true if v1 is greater than v2, false otherwise.

val (>=) : t -> t -> bool

v1 >= v2 returns true if v1 is greater or equal to v2, false otherwise.

val (<) : t -> t -> bool

v1 < v2 returns true if v2 is greater than v1, false otherwise.

val (<=) : t -> t -> bool

v1 <= v2 returns true if v2 is greater or equal to v1, false otherwise.