From 8ddf570a42d9baad61386c1238c07765d271f30e Mon Sep 17 00:00:00 2001 From: Matias Goldfeld <2000matu@gmail.com> Date: Wed, 27 Jan 2021 20:49:21 -0500 Subject: Fixed snowflake for 32 bit machines --- lib/models/snowflake.ml | 4 ++-- lib/models/snowflake.mli | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 2bf2281..f228bd7 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -10,10 +10,10 @@ let of_yojson d = let to_yojson s : Yojson.Safe.t = `String (Int.to_string s) -let timestamp snowflake = (snowflake lsr 22) + 1_420_070_400_000 +let timestamp snowflake = Int64.(+) (Int64.of_int (snowflake lsr 22)) 1_420_070_400_000L let time_of_t snowflake = - let t = timestamp snowflake |> float_of_int in + let t = timestamp snowflake |> Int64.to_float in Time.(Span.of_ms t |> of_span_since_epoch) diff --git a/lib/models/snowflake.mli b/lib/models/snowflake.mli index 0c42e4a..7d5cca8 100644 --- a/lib/models/snowflake.mli +++ b/lib/models/snowflake.mli @@ -6,7 +6,7 @@ type t = Int.t [@@deriving sexp, yojson { exn = true }] val time_of_t : t -> Time.t (** Convert a snowflake into a Unix timestamp. Millisecond precision. *) -val timestamp : t -> int +val timestamp : t -> int64 (** Convert a snowflake into an ISO8601 timestamp string. This is equivalent to calling [Snowflake.time_of_t snowflake |> Time.(to_string_iso8601_basic ~zone:Zone.utc)] *) val timestamp_iso : t -> string \ No newline at end of file -- cgit v1.2.3