123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2021-2022 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typerepr=Z.ttypet=Timestamp_tagofrepr[@@ocaml.unboxed]letcompare(Timestamp_tagx)(Timestamp_tagy)=Z.comparexyletof_int64i=Timestamp_tag(Z.of_int64i)letof_stringx=matchTime_repr.of_notationxwith|None->Option.catch(fun()->Timestamp_tag(Z.of_stringx))|Sometime->Some(of_int64(Time_repr.to_secondstime))letto_notation(Timestamp_tagx)=Option.catch(fun()->Time_repr.to_notation(Time.of_seconds(Z.to_int64x)))letto_num_str(Timestamp_tagx)=Z.to_stringxletto_stringx=matchto_notationxwithNone->to_num_strx|Somes->sletdiff(Timestamp_tagx)(Timestamp_tagy)=Script_int.of_zint@@Z.subxyletsub_delta(Timestamp_tagt)delta=Timestamp_tag(Z.subt(Script_int.to_zintdelta))letadd_delta(Timestamp_tagt)delta=Timestamp_tag(Z.addt(Script_int.to_zintdelta))letto_zint(Timestamp_tagx)=xletof_zintx=Timestamp_tagxletencoding=Data_encoding.(convto_zintof_zintz)letnowctxt=letopenAlpha_contextinletfirst_delay=Period.to_seconds(Constants.minimal_block_delayctxt)inletcurrent_timestamp=Timestamp.predecessorctxtinTime.addcurrent_timestampfirst_delay|>Timestamp.to_seconds|>of_int64