Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file caqti_prereq.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101(* Copyright (C) 2014--2018 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the OCaml static compilation exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*)openPrintfletidentx=xlet(%)gfx=g(fx)let(%>)fgx=g(fx)let(%>?)fgx=matchfxwithOky->gy|Error_asr->rlet(|>?)rf=matchrwithOkx->fx|Error_asr->rletrecncomposenfacc=ifn=0thenaccelsencompose(n-1)f(facc)moduleOption=structtype'at='aoptionletfoldf=functionNone->ident|Somex->fxendmoduleResult=structletmapf=functionOkx->Ok(fx)|Errore->ErroreendmoduleList=structincludeListletrecfoldf=function|[]->funacc->acc|x::xs->fx%>foldfxsletrecfold_rf=function|[]->funacc->Okacc|x::xs->fx%>?fold_rfxsletreciter_rf=function|[]->Ok()|x::xs->(matchfxwithOk()->iter_rfxs|Error_asr->r)endletfinallycleanupthunk=letr=trythunk()withxc->cleanup();raisexcincleanup();rletdatetuple_of_iso8601s=ifString.lengths=10&&s.[4]='-'&&s.[7]='-'then(int_of_string(String.subs04),int_of_string(String.subs52),int_of_string(String.subs82))elsefailwith"Caqti_internal.datetuple_of_iso8601"letiso8601_of_datetuple(y,m,d)=sprintf"%04d-%02d-%02d"ymdletstring_of_rfc3339_error~inputerr=letbuf=Buffer.create64inletppf=Format.formatter_of_bufferbufinPtime.pp_rfc3339_errorppferr;Format.fprintfppf" in value %S."input;Format.pp_print_flushppf();Buffer.contentsbufletptime_of_rfc3339_utcs=letn=String.lengthsinlets=ifn<13thenselseifs.[n-1]='Z'thenselseifs.[n-3]='+'||s.[n-3]='-'thens^":00"elseifs.[n-6]='+'||s.[n-6]='-'thenselses^"Z"in(matchPtime.of_rfc3339swith|Ok(t,(None|Some0),_)->Okt|Ok(_,Some_,_)->Error"Non-UTC time."|Error(`RFC3339(_,err))->Error(string_of_rfc3339_error~input:serr))letpdate_of_iso8601s=(matchPtime.of_date(datetuple_of_iso8601s)with|exceptionFailure_->Error(sprintf"Cannot parse date %S."s)|None->Error(sprintf"Date %s is out of range."s)|Somepdate->Okpdate)letiso8601_of_pdatex=iso8601_of_datetuple(Ptime.to_datex)letdefault_log_src=Logs.Src.create"caqti"