diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2017-11-08 17:01:04 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2017-11-08 17:01:04 +0100 |
commit | 163a82655b1b3649c9bff4db05f487db3a992a40 (patch) | |
tree | b7308ea89caef819825683551b6ceb9fc6c72369 /scTypes.ml | |
parent | 5eb60432c81bd13f26852a4cef9b1a570002883d (diff) |
Update functions
Diffstat (limited to 'scTypes.ml')
-rwxr-xr-x | scTypes.ml | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -127,7 +127,7 @@ module Type = struct show_list printer buffer tl end - and show: type a. UTF8.Buffer.buffer -> a types -> unit = fun buffer -> begin function + let show: type a. UTF8.Buffer.buffer -> a types -> unit = fun buffer -> begin function | Str x -> UTF8.Buffer.add_string buffer x | Bool b -> UTF8.Printf.bprintf buffer "%B" b | Num (Number, n) -> @@ -146,6 +146,25 @@ module Type = struct UTF8.Printf.bprintf buffer "%d/%d/%d" y m d end + let show_full: type a. UTF8.Buffer.buffer -> a types -> unit = fun buffer -> begin function + | Str x -> UTF8.Buffer.add_string buffer x + | Bool b -> UTF8.Printf.bprintf buffer "%B" b + | Num (Number, n) -> + if DataType.Num.is_integer n then + DataType.Num.to_int n + |> string_of_int + |> UTF8.from_utf8string + |> UTF8.Buffer.add_string buffer + else + let f = DataType.Num.to_float n + and to_b = UTF8.Format.formatter_of_buffer buffer in + ignore @@ UTF8.Format.fprintf to_b "%f" f; + Format.pp_print_flush to_b () + | Num (Date, n) -> + let y, m, d = DataType.Date.date_from_julian_day n in + UTF8.Printf.bprintf buffer "%d/%d/%d" y m d + end + type t = | Value: 'a dataFormat * 'a -> t |