diff options
Diffstat (limited to 'lib/models/snowflake.ml')
| -rw-r--r-- | lib/models/snowflake.ml | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index f228bd7..92d94fa 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,16 +1,8 @@ open Core
-type t = Int.t [@@deriving sexp]
+type t = int64 [@@deriving sexp, yojson]
-let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.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 (Int.to_string s)
-
-let timestamp snowflake = Int64.(+) (Int64.of_int (snowflake lsr 22)) 1_420_070_400_000L
+let timestamp snowflake = Int64.((snowflake lsr 22) + 1_420_070_400_000L)
let time_of_t snowflake =
let t = timestamp snowflake |> Int64.to_float in
|