package caqti
Unified interface to relational database libraries
Install
Dune Dependency
Authors
Maintainers
Sources
caqti-v2.1.2.tbz
sha256=ba4dfd5ff94376b5e003f682410b7b3b392c0bbaa0253679fe7671c2e07e895b
sha512=0416807fba620429ee4d64f3a6991238112e0e10dfba9703dced46cf332fd22135a9873007d025441228ce66fb192bf730d4bc776dd2c1a973d7604ab6e789e0
doc/src/caqti.platform/conv.ml.html
Source file conv.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
(* Copyright (C) 2019--2022 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 LGPL-3.0 Linking 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 * and the LGPL-3.0 Linking Exception along with this library. If not, see * <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *) open Printf let datetuple_of_iso8601 s = if String.length s = 10 && s.[4] = '-' && s.[7] = '-' then try (int_of_string (String.sub s 0 4), int_of_string (String.sub s 5 2), int_of_string (String.sub s 8 2)) with Failure _ -> failwith "Caqti_platform.datetuple_of_iso8601" else failwith "Caqti_platform.datetuple_of_iso8601" let iso8601_of_datetuple (y, m, d) = sprintf "%04d-%02d-%02d" y m d let string_of_rfc3339_error ~input err = let buf = Buffer.create 64 in let ppf = Format.formatter_of_buffer buf in Ptime.pp_rfc3339_error ppf err; Format.fprintf ppf " in value %S." input; Format.pp_print_flush ppf (); Buffer.contents buf let ptime_of_rfc3339_utc s = let n = String.length s in let s' = if n < 13 then s else if s.[n - 1] = 'Z' then s else if s.[n - 3] = '+' || s.[n - 3] = '-' then s ^ ":00" else if s.[n - 6] = '+' || s.[n - 6] = '-' then s else s ^ "Z" in (match Ptime.of_rfc3339 s' with | Ok (t, _, _) -> Ok t | Error (`RFC3339 (_, err)) -> Error (string_of_rfc3339_error ~input:s' err)) let pdate_of_iso8601 s = (match Ptime.of_date (datetuple_of_iso8601 s) with | exception Failure _ -> Error (sprintf "Cannot parse date %S." s) | None -> Error (sprintf "Date %s is out of range." s) | Some pdate -> Ok pdate) let iso8601_of_pdate x = iso8601_of_datetuple (Ptime.to_date x)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>