add time.ml, similar to libgnunetutil's

This commit is contained in:
swrup 2026-02-05 15:31:49 +01:00
parent 5eba5f2265
commit 11a13f0dfe
17 changed files with 333 additions and 319 deletions

View file

@ -18,13 +18,34 @@ open Offline_impl
module Arg = struct
include Arg
(* in seconds *)
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 -> Ok (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 ()
(* in seconds *)
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 s -> Ok (Time.Relative.of_s (Int64.of_int s))
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

View file

@ -101,7 +101,7 @@ let global_fees ~output ~master_key ~start_date ~end_date ~history_fee
let master_sig =
let open Bin_sig.GlobalFees in
(* TODO KYC *)
let kyc_timeout = None in
let kyc_timeout = Time.Relative.forever in
let kyc_fee = Amount.dummy_value in
sign_f ~f:(EddsaSignature.sign ~key)
{