diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-28 10:31:51 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-28 10:31:51 -0700 |
| commit | 8662e92987c437f59d09896a247ec2b5d82c4528 (patch) | |
| tree | f004cc14598351d4ad6b19d8e993d2f629c5e738 /lib/models/snowflake.ml | |
| parent | Add more docs (diff) | |
| download | disml-8662e92987c437f59d09896a247ec2b5d82c4528.tar.xz disml-8662e92987c437f59d09896a247ec2b5d82c4528.zip | |
Publish docs updates
Diffstat (limited to 'lib/models/snowflake.ml')
| -rw-r--r-- | lib/models/snowflake.ml | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 3b55493..44b0a48 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -1,22 +1,22 @@ -open Core - -type t = Int.t [@@deriving sexp] - -let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string - -let of_yojson 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) - -let timestamp snowflake = (snowflake lsr 22) + 1_420_070_400_000 - -let time_of_t snowflake = - let t = timestamp snowflake |> float_of_int in - Time.(Span.of_ms t - |> of_span_since_epoch) - -let timestamp_iso snowflake = - time_of_t snowflake +open Core
+
+type t = Int.t [@@deriving sexp]
+
+let of_yojson_exn d = Yojson.Safe.Util.to_string d |> Int.of_string
+
+let of_yojson 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)
+
+let timestamp snowflake = (snowflake lsr 22) + 1_420_070_400_000
+
+let time_of_t snowflake =
+ let t = timestamp snowflake |> float_of_int in
+ Time.(Span.of_ms t
+ |> of_span_since_epoch)
+
+let timestamp_iso snowflake =
+ time_of_t snowflake
|> Time.(to_string_iso8601_basic ~zone:Zone.utc)
\ No newline at end of file |