package lunar

  1. Overview
  2. Docs
A very small date management library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

lunar-1.1.0.tbz
sha256=f158deac67b864f3edd7d1242b3340a0f218d4465b9e4108501a02197594d0f9
sha512=acf9a3ea508c3df2351aec6ea8299583be128f02d2d891ab82a2999ad6ba00c967962ede7d96782c27a7edcb7f78db08380293a8bf044a567a749872bbc417a8

doc/lunar/Lunar/Month/index.html

Module Lunar.MonthSource

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

Type

Sourcetype t =
  1. | Jan
  2. | Feb
  3. | Mar
  4. | Apr
  5. | May
  6. | Jun
  7. | Jul
  8. | Aug
  9. | Sep
  10. | Oct
  11. | Nov
  12. | Dec

Type describing a month of the year.

Sourcetype error =
  1. | Invalid_month_number of int
  2. | Invalid_month_string of string

Type listing errors that may occur when working with months.

Sourceval all : t list

all is a list of all month from January to December.

Operation and facts

Sourceval from_int : int -> (t, error) result

from_int i converts an integer (1-based) to months.

Sourceval to_int : t -> int

to_int m returns the numeric representation of a month (1-based).

Sourceval to_string : t -> string

to_string m returns the string representation of a month (not capitalized).

Sourceval to_short_string : t -> string

to_short_string m returns the short string representation of a month (not capitalized), ie: "jan" for "january".

Sourceval from_string : string -> (t, error) result

from_string str try to convert a string to a month. (Using string representation or short representation).

Sourceval days_in : year:int -> t -> int

days_in ~year m Returns the number of days in month m for a given year year.

Sourceval quarter_of : t -> t * t

quarter_of m Returns the months that make up the quarter in which the given month falls.

Sourceval succ : t -> t

succ m returns the following month.

Sourceval pred : t -> t

pred m returns the previous month.

Sourceval equal : t -> t -> bool

equal a b is equality between a and b.

Sourceval compare : t -> t -> int

compare a b comparison between month, 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.