From 3ba30fa4688fe94fdba82178fde72e11385c3df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 16 Apr 2018 00:44:24 +0200 Subject: [PATCH] RPC: allow 'epoch' as a valid `Time.rpc_arg` --- src/lib_base/time.ml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib_base/time.ml b/src/lib_base/time.ml index 9bcb86701..21a331505 100644 --- a/src/lib_base/time.ml +++ b/src/lib_base/time.ml @@ -113,10 +113,18 @@ module T = struct ~descr:(Format.asprintf "A date in seconds from epoch") ~destruct: (fun s -> - match Int64.of_string s with - | exception _ -> - Error (Format.asprintf "failed to parse time (epoch): %S" s) - | v -> Ok v) + if s = "none" || s = "epoch" then + Ok epoch + else + match of_notation s with + | None -> begin + match Int64.of_string s with + | exception _ -> begin + Error (Format.asprintf "failed to parse time (epoch): %S" s) + end + | t -> Ok t + end + | Some t -> Ok t) ~construct:Int64.to_string ()