type t = { created: Ptime.t option; edited: Ptime.t option } let compare = compare let rfc_string date = match date with Some t -> Ptime.to_rfc3339 t | None -> "" let of_string (rfc : string) = match Ptime.of_rfc3339 rfc with Ok (t,_,_) -> Some t | Error _ -> None let listing date = if Option.is_some date.edited then date.edited else date.created let pretty_date = function | Some t -> Ptime.to_date t |> fun (y, m, d) -> Printf.sprintf "%04d-%02d-%02d" y m d | None -> ""