aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Goldfeld <[email protected]>2021-01-27 20:49:21 -0500
committerMatias Goldfeld <[email protected]>2021-01-27 20:49:21 -0500
commit8ddf570a42d9baad61386c1238c07765d271f30e (patch)
treea8d1751e035bedfea9edb1e1b838e4a6f381a140
parentAdded message_reference functionality (diff)
downloaddisml-8ddf570a42d9baad61386c1238c07765d271f30e.tar.xz
disml-8ddf570a42d9baad61386c1238c07765d271f30e.zip
Fixed snowflake for 32 bit machines
-rw-r--r--lib/models/snowflake.ml4
-rw-r--r--lib/models/snowflake.mli2
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