aboutsummaryrefslogtreecommitdiff
path: root/scTypes.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2017-11-08 17:01:04 +0100
committerSébastien Dailly <sebastien@chimrod.com>2017-11-08 17:01:04 +0100
commit163a82655b1b3649c9bff4db05f487db3a992a40 (patch)
treeb7308ea89caef819825683551b6ceb9fc6c72369 /scTypes.ml
parent5eb60432c81bd13f26852a4cef9b1a570002883d (diff)
Update functions
Diffstat (limited to 'scTypes.ml')
-rwxr-xr-xscTypes.ml21
1 files changed, 20 insertions, 1 deletions
diff --git a/scTypes.ml b/scTypes.ml
index 075f25d..48e4d3c 100755
--- a/scTypes.ml
+++ b/scTypes.ml
@@ -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