Module Timmy.Week

A week of a year.

A week of a year.

Type

type t = {
  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.

val schema_versioned : Schematic.Schema.version -> t Schematic.Schema.t
val schema : t Schematic.Schema.t

Week schema.

type js = < n : Js_of_ocaml.Js.number Js_of_ocaml.Js.readonly_prop ; year : Js_of_ocaml.Js.number Js_of_ocaml.Js.readonly_prop > Js_of_ocaml.Js.t

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.