From b9ee77f8153090e9d47e73ab195540d10720c7b6 Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Thu, 10 Jan 2019 13:12:49 -0700 Subject: AAAAAAAAAAAAAAAAAAAAAAAA --- lib/models/snowflake.ml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'lib/models/snowflake.ml') diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 6b52ec6..28b7fdb 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,16 +1,14 @@ -module Make(Http : S.Http) = struct - open Core +open Core - type t = Snowflake_t.t +type t = int [@@deriving yojson] - let timestamp snowflake = - let offset = (snowflake lsr 22) / 1000 in - 1_420_070_400 + offset +let timestamp snowflake = + let offset = (snowflake lsr 22) / 1000 in + 1_420_070_400 + offset - let timestamp_iso snowflake = - let t = timestamp snowflake in - Date.( - of_time ~zone:Time.Zone.utc - Time.(of_span_since_epoch @@ Span.of_int_sec t) - |> format) "%FT%T+00:00" -end \ No newline at end of file +let timestamp_iso snowflake = + let t = timestamp snowflake in + Date.( + of_time ~zone:Time.Zone.utc + Time.(of_span_since_epoch @@ Span.of_int_sec t) + |> format) "%FT%T+00:00" \ No newline at end of file -- cgit v1.2.3 From b7f8f0de01c5014703376d7204b62d8e47c9179a Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Thu, 10 Jan 2019 16:15:20 -0700 Subject: Fix some deserializing bits --- lib/models/snowflake.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/models/snowflake.ml') diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 28b7fdb..9e630e1 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,6 +1,14 @@ open Core -type t = int [@@deriving yojson] +type t = int + +let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string |> Ok + +let of_yojson d = + try of_yojson_exn d + with Yojson.Safe.Util.Type_error (why,_) -> Error why + +let to_yojson s : Yojson.Safe.json = `String (Int.to_string s) let timestamp snowflake = let offset = (snowflake lsr 22) / 1000 in -- cgit v1.2.3 From cba1fa3ab1b085600f3a73dae62682d21d112afb Mon Sep 17 00:00:00 2001 From: Adelyn Breelove Date: Fri, 11 Jan 2019 12:44:22 -0700 Subject: More deserialization fixes --- lib/models/snowflake.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/models/snowflake.ml') diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 9e630e1..21846fc 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -2,10 +2,10 @@ open Core type t = int -let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string |> Ok +let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string let of_yojson d = - try of_yojson_exn d + try of_yojson_exn d |> Ok with Yojson.Safe.Util.Type_error (why,_) -> Error why let to_yojson s : Yojson.Safe.json = `String (Int.to_string s) -- cgit v1.2.3 From c5bfc108ca6a1e7a21492b4318de78a74ed801f9 Mon Sep 17 00:00:00 2001 From: Adelyn Breedlove Date: Sun, 13 Jan 2019 16:51:04 -0700 Subject: Add deriving sexp to models --- lib/models/snowflake.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/models/snowflake.ml') diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 21846fc..0122da8 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,6 +1,6 @@ open Core -type t = int +type t = Int.t [@@deriving sexp] let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string -- cgit v1.2.3