aboutsummaryrefslogtreecommitdiff
path: root/lib/models/snowflake.ml
diff options
context:
space:
mode:
authorMatias Goldfeld <[email protected]>2021-01-28 02:26:36 -0500
committerMatias Goldfeld <[email protected]>2021-01-28 02:26:36 -0500
commitc937240fdd2036edd493debb76117165e4084e8b (patch)
treeb0d89ca5795724b3bb804f2d65ee609217567ecd /lib/models/snowflake.ml
parentMore Int64 refactors (diff)
downloaddisml-c937240fdd2036edd493debb76117165e4084e8b.tar.xz
disml-c937240fdd2036edd493debb76117165e4084e8b.zip
Started conversion to ppx_yojson_conv
Diffstat (limited to 'lib/models/snowflake.ml')
-rw-r--r--lib/models/snowflake.ml10
1 files changed, 1 insertions, 9 deletions
diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml
index 868b2b9..92d94fa 100644
--- a/lib/models/snowflake.ml
+++ b/lib/models/snowflake.ml
@@ -1,14 +1,6 @@
open Core
-type t = int64 [@@deriving sexp]
-
-let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int64.of_string
-
-let of_yojson d =
- try Ok (of_yojson_exn d)
- with Yojson.Safe.Util.Type_error (why,_) -> Error why
-
-let to_yojson s : Yojson.Safe.t = `String (Int64.to_string s)
+type t = int64 [@@deriving sexp, yojson]
let timestamp snowflake = Int64.((snowflake lsr 22) + 1_420_070_400_000L)