This commit is contained in:
parent
7e7bc836d1
commit
ea6b2d43fe
1 changed files with 21 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
module T = struct
|
||||||
type t = Ptime.t
|
type t = Ptime.t
|
||||||
type span = Ptime.span
|
type span = Ptime.span
|
||||||
|
|
||||||
|
|
@ -20,8 +21,8 @@ let of_int_s s = Ptime.of_span @@ span_of_int_s s
|
||||||
let of_int64_us us = Ptime.of_span @@ span_of_int64_us us
|
let of_int64_us us = Ptime.of_span @@ span_of_int64_us us
|
||||||
let to_int_s t = Ptime.Span.to_int_s (Ptime.to_span t)
|
let to_int_s t = Ptime.Span.to_int_s (Ptime.to_span t)
|
||||||
|
|
||||||
let to_int64_us span =
|
let to_int64_us t =
|
||||||
match to_int_s span with
|
match to_int_s t with
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some s ->
|
| Some s ->
|
||||||
let us = Int64.(mul (of_int s) 1_000_000_L) in
|
let us = Int64.(mul (of_int s) 1_000_000_L) in
|
||||||
|
|
@ -31,6 +32,24 @@ let now () = Ptime_clock.now ()
|
||||||
let add_span t span = Ptime.add_span t span
|
let add_span t span = Ptime.add_span t span
|
||||||
let sub_span t span = Ptime.sub_span t span
|
let sub_span t span = Ptime.sub_span t span
|
||||||
let diff a b = Ptime.diff a b
|
let diff a b = Ptime.diff a b
|
||||||
|
end
|
||||||
|
|
||||||
|
type t = | T_uint64_us of int64 | Never
|
||||||
|
|
||||||
|
let to_uint64 =
|
||||||
|
function | T_uint64_us us -> us | Never -> (* never/forever case := uint64_max *)
|
||||||
|
-1L
|
||||||
|
|
||||||
|
let of_uint64 us =
|
||||||
|
if us = -1L then Never else T_uint64_us us
|
||||||
|
|
||||||
|
let now () =
|
||||||
|
let opt = T.to_int64_us @@
|
||||||
|
Ptime_clock.now () in
|
||||||
|
match opt with
|
||||||
|
| None -> Fmt.failure "invalid Ptime_clock.now value"
|
||||||
|
| Some us ->
|
||||||
|
|
||||||
(*
|
(*
|
||||||
(* microseconds since the UNIX Epoch, or "never" if None *)
|
(* microseconds since the UNIX Epoch, or "never" if None *)
|
||||||
let jsont =
|
let jsont =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue