diff options
| author | Adelyn Breedlove <[email protected]> | 2019-01-20 23:55:56 -0700 |
|---|---|---|
| committer | Adelyn Breedlove <[email protected]> | 2019-01-20 23:55:56 -0700 |
| commit | 916a7fe93cb43a127ae08d545f5fddf2a4ea74be (patch) | |
| tree | 4784cce76f45b4083364fb7a4f9968e879887780 /lib/models/snowflake.ml | |
| parent | Improve embed builders (diff) | |
| download | disml-916a7fe93cb43a127ae08d545f5fddf2a4ea74be.tar.xz disml-916a7fe93cb43a127ae08d545f5fddf2a4ea74be.zip | |
Add more interfaces
Diffstat (limited to 'lib/models/snowflake.ml')
| -rw-r--r-- | lib/models/snowflake.ml | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/models/snowflake.ml b/lib/models/snowflake.ml index 0122da8..4c87d63 100644 --- a/lib/models/snowflake.ml +++ b/lib/models/snowflake.ml @@ -10,13 +10,10 @@ let of_yojson d = let to_yojson s : Yojson.Safe.json = `String (Int.to_string s) -let timestamp snowflake = - let offset = (snowflake lsr 22) / 1000 in - 1_420_070_400 + offset +let timestamp snowflake = (snowflake lsr 22) + 1_420_070_400_000 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 + let t = timestamp snowflake |> float_of_int in + Time.(Span.of_ms t + |> of_span_since_epoch + |> to_string_iso8601_basic ~zone:Zone.utc)
\ No newline at end of file |