From 28ca4d1ff8774352f9b7a6fc271ba0a8e56cdc9a Mon Sep 17 00:00:00 2001 From: swrup Date: Thu, 5 Feb 2026 15:31:49 +0100 Subject: [PATCH] --- tools/offline.ml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) 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