10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-06-17 18:55:18 +02:00
qmcchem/ocaml/Time.ml

27 lines
476 B
OCaml
Raw Normal View History

2019-07-19 11:46:29 +02:00
let of_sec s =
Unix.gmtime s
let to_sec t =
let sec = t.Unix.tm_sec
and min = t.Unix.tm_min
and hour = t.Unix.tm_hour
and mday = t.Unix.tm_mday
in
sec +
min * 60 +
hour * 60 * 60 +
mday * 60 * 60 * 24
let string_of_t t =
let mday = t.Unix.tm_mday in
let sec = t.Unix.tm_sec
and min = t.Unix.tm_min
and hour = t.Unix.tm_hour + 24*mday
in
Printf.sprintf "%2d:%2d:%2d" hour min sec
let string_of_sec s =
of_sec s
|> string_of_t