This commit is contained in:
parent
5eba5f2265
commit
7a28fb55ca
17 changed files with 325 additions and 314 deletions
|
|
@ -150,6 +150,7 @@ module Parse_duration = struct
|
|||
|
||||
let duration = many1 duration_element <* end_of_input
|
||||
|
||||
(* TODO put this in Time.Relative *)
|
||||
let dunit_to_seconds u =
|
||||
let rec f = function
|
||||
| `Year -> 365 * f `Day
|
||||
|
|
@ -167,15 +168,14 @@ module Parse_duration = struct
|
|||
fail "ptime_span_of_int64 error: `%Ld` is not a valid ptime span" i
|
||||
| Some ts -> ts
|
||||
|
||||
let to_ptime_span t =
|
||||
let to_time_span t =
|
||||
let acc =
|
||||
List.fold_left
|
||||
(fun acc { number; dunit } -> acc + (number * dunit_to_seconds dunit))
|
||||
0 t
|
||||
in
|
||||
let acc = Int64.of_int acc in
|
||||
let ptime = ptime_span_of_int64 acc in
|
||||
ptime
|
||||
Time.Relative.of_s acc
|
||||
|
||||
let parse s : duration_element list =
|
||||
match parse_string ~consume:All duration s with
|
||||
|
|
@ -218,7 +218,7 @@ let yes_no = function
|
|||
|
||||
let uri s = Uri.of_string s
|
||||
let amount s = s |> Amount.of_string |> unwrap_res
|
||||
let duration s = Parse_duration.(s |> parse |> to_ptime_span)
|
||||
let duration s = Parse_duration.(s |> parse |> to_time_span)
|
||||
|
||||
let ed25519 s =
|
||||
s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue