diff --git a/tools/offline.ml b/tools/offline.ml index d749813d..8484367c 100644 --- a/tools/offline.ml +++ b/tools/offline.ml @@ -19,12 +19,31 @@ module Arg = struct include Arg let timestamp = - Arg.Conv.make ~docv:"timestamp argument" ~parser:Timestamp.of_string - ~pp:Timestamp.pp () + let parser s = + match int_of_string_opt s with + | None -> Error "not an int" + | Some n -> Time.Timestamp.of_s (Int64.of_int n) + in + let pp fmt t = + match Time.Timestamp.to_s t with + | None -> Fmt.pf fmt "never" + | Some s -> Fmt.pf fmt "%Ld" s + in + Arg.Conv.make ~docv:"timestamp argument" ~parser ~pp () let relative_time = - Arg.Conv.make ~docv:"relative time argument" - ~parser:Timestamp.Span.of_string ~pp:Timestamp.Span.pp () + let parser s = + match int_of_string_opt s with + | None -> Error "not an int" + | Some n -> Time.Relative.of_s (Int64.of_int n) + in + let pp fmt d = + let t = Time.Timestamp.of_absolute Time.Absolute.(add zero d) in + match Time.Timestamp.to_s t with + | None -> Fmt.pf fmt "never" + | Some s -> Fmt.pf fmt "%Ld" s + in + Arg.Conv.make ~docv:"relative time argument" ~parser ~pp () let b32 = let pp fmt v = Fmt.pf fmt "%s" (B32.encode v) in