diff --git a/src/ymd.ml b/src/ymd.ml index d8725ba..e670ed3 100644 --- a/src/ymd.ml +++ b/src/ymd.ml @@ -41,8 +41,11 @@ let rfc_string_of date = match date with let date_of (rfc : string) = match Ptime.of_rfc3339 rfc with Ok (t,_,_) -> Some t | Error _ -> None;; -let date_string ymd = match ymd.meta.date.published with +let modification_date ymd = match ymd.meta.date.published with Some t -> Some t | None -> ymd.meta.date.edited +let pretty_date_of t = match t with + | Some t -> Ptime.to_date t |> fun (y, m, d) -> Printf.sprintf "%04d-%02d-%02d" y m d + | None -> "" let trim_str v = v |> String.trim let list_of_csv = Re_str.(split (regexp " *, *")) diff --git a/src/ymd.mli b/src/ymd.mli index c8b9759..557798b 100644 --- a/src/ymd.mli +++ b/src/ymd.mli @@ -58,7 +58,8 @@ val with_meta_kv : meta -> string * string -> meta val rfc_string_of : Ptime.t option -> string val date_of : string -> Ptime.t option -val date_string : ymd -> Ptime.t option +val modification_date : ymd -> Ptime.t option +val pretty_date_of : Ptime.t option -> string (** {1 Lenses for accessing [ymd] record fields} *)