Something went wrong. Try again.
Correctness- and interoperability-oriented Tangled CLI
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031type t = Ptime.t
let of_string value = match Ptime.of_rfc3339 value with | Ok (timestamp, _, _) -> Ok timestamp | Error _ -> Error "timestamp must be valid RFC 3339"
let of_float_s value = match Ptime.of_float_s value with | Some timestamp -> Ok (Ptime.truncate ~frac_s:6 timestamp) | None -> Error "timestamp is outside the supported range"
let trim_fraction value = match String.index_opt value '.' with | None -> value | Some separator -> let zone = String.length value - 1 in let rec last_significant index = if index > separator && Char.equal value.[index] '0' then last_significant (index - 1) else index in let last = last_significant (zone - 1) in if last = separator then String.sub value 0 separator ^ "Z" else String.sub value 0 (last + 1) ^ "Z"
let to_string value = Ptime.to_rfc3339 ~frac_s:12 ~tz_offset_s:0 value |> trim_fraction
let compare = Ptime.compare