RPC: allow 'epoch' as a valid Time.rpc_arg

This commit is contained in:
Grégoire Henry 2018-04-16 00:44:24 +02:00
parent d3f4424c75
commit 3ba30fa468

View File

@ -113,10 +113,18 @@ module T = struct
~descr:(Format.asprintf "A date in seconds from epoch")
~destruct:
(fun s ->
if s = "none" || s = "epoch" then
Ok epoch
else
match of_notation s with
| None -> begin
match Int64.of_string s with
| exception _ ->
| exception _ -> begin
Error (Format.asprintf "failed to parse time (epoch): %S" s)
| v -> Ok v)
end
| t -> Ok t
end
| Some t -> Ok t)
~construct:Int64.to_string
()