ligo/lib_embedded_protocol_alpha/src/time_repr.ml
Grégoire Henry 9cb498eee6 Jbuilder: Move alpha/genesis/demo in their own two OPAM packages
One package for the embedded version. One for the functorized one.
2017-12-04 16:05:54 +01:00

28 lines
992 B
OCaml

(**************************************************************************)
(* *)
(* Copyright (c) 2014 - 2017. *)
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
include Time
type time = t
type error += Timestamp_add of exn
let of_seconds s =
try Some (of_seconds (Int64.of_string s))
with _ -> None
let to_seconds = to_seconds
let to_seconds_string s = Int64.to_string (to_seconds s)
let pp = pp_hum
let (+?) x y =
(* TODO check overflow *)
try ok (add x (Period_repr.to_seconds y))
with exn -> Error [Timestamp_add exn]