package timmy

  1. Overview
  2. Docs

A week of a year.

A week of a year.

Type

type t = private {
  1. year : int;
  2. n : int;
}

A week of a year.

Per ISO 8601 week date system, a week is attributed to the year its Thursday is in.

Construction

val make : year:Base.int -> Base.int -> (t, Base.string) Base.Result.t

make ~year n is { n; year } if it represents a valid week or a relevant error message otherwise.

Time manipulation

val days : t -> Date.t Base.Sequence.t

days week is the sequence of dates in week in chronological order.

val day : t -> Weekday.t -> Date.t

day week weekday is the weekday of week.

Time conversions

val to_date : t -> Date.t

to_date week is the first day (Monday) of week

val of_date : Date.t -> t

of_date date is the week that includes date

Comparison

include Base.Comparable.S with type t := t
val equal : t -> t -> bool
val compare : t -> t -> int
val min : t -> t -> t
val max : t -> t -> t
val ascending : t -> t -> int
val descending : t -> t -> int
val between : t -> low:t -> high:t -> bool
val clamp_exn : t -> min:t -> max:t -> t
val clamp : t -> min:t -> max:t -> t Base__.Or_error.t
type comparator_witness
val comparator : (t, comparator_witness) Base__Comparator.comparator

Operators

module O : sig ... end

Convenience module to only pull operators.

include module type of O

Convenience module to only pull operators.

include Base.Comparable.Infix with type t := t
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val (+) : t -> Base.int -> t

time + span is the time point span after time.

Scalar conversions

Pretty-print

val pp : t Fmt.t

pp f week prints week to f in YYYY-NN format, eg. 2021-02.

String

val to_string : t -> Base.string

to_string week is the YYYY-WW representation of week, eg. 2022-03.

val of_string : Base.string -> (t, Base.string) Base.Result.t

of_string s is the week represented by s as yielded by to_string or a relevant error message if it is invalid.

OCaml

Innovation. Community. Security.