15 lines
727 B
OCaml
15 lines
727 B
OCaml
type t = { created: string; edited: string }
|
|
let compare = compare
|
|
let rfc_string date = date
|
|
let of_string (rfc : string) = rfc
|
|
let listing date = if date.edited <> "" then date.edited else date.created
|
|
let pretty_date date =
|
|
try Scanf.sscanf date "%4s-%2s-%2s" (fun y m d -> Printf.sprintf "%s %s %s" y m d)
|
|
with Scanf.Scan_failure s as e -> Printf.fprintf stderr "%s for %s\n" s date; raise e
|
|
let now () = Unix.time () |> Unix.gmtime |>
|
|
(fun t -> Printf.sprintf "%4d-%02d-%02dT%02d:%02d:%02dZ"
|
|
(t.tm_year+1900) (t.tm_mon+1) t.tm_mday t.tm_hour t.tm_min t.tm_sec)
|
|
let to_secs date =
|
|
Scanf.sscanf date "%4d-%02d-%02dT%02d:%02d:%02d"
|
|
(fun y mo d h mi s -> (y-1970)*31557600 + mo*2629800 + d*86400 + h*3600 + mi*60 + s)
|