aboutsummaryrefslogtreecommitdiff
path: root/scTypes.ml
diff options
context:
space:
mode:
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