Module Lunar

Lunar is a minimal date and time library, based primarily on a proleptic Gregorian calendar, that focuses on simple operations. Its development is needs-driven, meaning that the library is open to contributions that add use cases not initially considered.

In particular, the library allows you to work with Time objects (a specific hour of the day), Date objects (a specific day of the year), Datetime objects (a combination of a Time and a Date), and Zoned_datetime objects (a Datetime associated with a Timezone).

The code (and the algorithms used) is designed to be as simple as possible and easy to extend (without any particular concern for performance... sorry).

Components

Describes the low-level components used as utilities for describing dates.

module Era : sig ... end

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.

module Month : sig ... end

Representation of the months of the year, using an enumeration.

module Weekday : sig ... end

Representation of the days of a week, using an enumeration.

Absolute elements

All objects that are not associated with a time zone.

module Time : sig ... end

Represents a time from 00:00:00 to 23:59:59.

module Date : sig ... end

Represents a date (year, month, day).

module Datetime : sig ... end

Represents a Datetime. A Date.t associated with a Time.t.

Relative elements

Objects associated with a time zone.

module Timezone : sig ... end

Describes the offset of a time zone, used to describe time-zone datetime values.

module Zoned_datetime : sig ... end

A Datetime.t associated with a Timezone.t.

Resolution and Duration

The resolution allows you to truncate dates (and more). And durations are a low-level representation of a number of seconds.

module Resolution : sig ... end

Describes a resolution that allows, among other things, dates to be truncated. Since negative resolutions produce strange results, they are always converted to their absolute values.

module Duration : sig ... end

Describes a duration in seconds (Lunar is essentially a Calendar library, so greater precision does not seem particularly useful). This is the most primitive type in the library, and the API exposes minimal set of arithmetic operations.

Ranges

Provides a generic way to describe orderable and iterable ranges.

module Range : sig ... end

The Range module allows you to create intervals between comparable data points (implementing Sigs.COMPARABLE).

Reusable signatures

module Sigs : sig ... end

Set of reusable signatures for sharing behaviors, among other things.