diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-11 11:15:18 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-11 11:15:18 +0200 |
| commit | d532c3b2cf941d2fe0c3c84f2c4090f14e869ef0 (patch) | |
| tree | ba8f4bb56157989d5874ede8ae463a36812c0001 /lib/kernel/date.mli | |
| parent | 1d6b9a540a50159221e0475bc1c1c2387d417622 (diff) | |
| download | colitur-d532c3b2cf941d2fe0c3c84f2c4090f14e869ef0.tar.gz colitur-d532c3b2cf941d2fe0c3c84f2c4090f14e869ef0.zip | |
kernel(date): ISO-8601 rendering, validating parse, sexp converters
Adds sexplib and ppx_sexp_conv to the project and wires the ppx into the
kernel library. Date's sexp form is an ISO-8601 atom rather than the opaque
rata die, so data files stay human-editable and parsing revalidates the
1583..9999 domain.
Diffstat (limited to 'lib/kernel/date.mli')
| -rw-r--r-- | lib/kernel/date.mli | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/kernel/date.mli b/lib/kernel/date.mli index b684d61..2f632c8 100644 --- a/lib/kernel/date.mli +++ b/lib/kernel/date.mli @@ -3,7 +3,7 @@ arithmetic and comparison are total and cheap. *) type t -type weekday = Sun | Mon | Tue | Wed | Thu | Fri | Sat +type weekday = Sun | Mon | Tue | Wed | Thu | Fri | Sat [@@deriving sexp] (** [make ~year ~month ~day] validates the date; rejects a month/day out of range and any year outside 1583..9999. *) @@ -21,3 +21,16 @@ val to_rata : t -> int val of_rata : int -> t val add_days : t -> int -> t val compare : t -> t -> int + +(** ISO-8601 rendering and validating parsing. [of_iso8601] enforces the same + domain as {!make}. *) +val to_iso8601 : t -> string +val of_iso8601 : string -> (t, string) result + +val weekday_to_string : weekday -> string + +(** Sexp form is an ISO-8601 atom, e.g. [2026-04-05]. [t_of_sexp] validates and + raises [Of_sexp_error] on a malformed or out-of-domain date; loaders convert + that to a [result]. *) +val t_of_sexp : Sexplib0.Sexp.t -> t +val sexp_of_t : t -> Sexplib0.Sexp.t |
