Snowflake v1.0.2 Snowflake.Util

The Util module helps users work with snowflake IDs.

Util module can do the following:

  • Deriving timestamp based on ID
  • Creating buckets based on days since epoch…
  • get real timestamp of any ID

Summary

Functions

When no id is provided, we generate a bucket for the current time

Get bucket value based on segments of N days

First Snowflake for timestamp, useful if you have a timestamp and want to find snowflakes before or after a certain millesecond

Get timestamp from computer epoch - January 1, 1970, Midnight

Get timestamp in ms from your config epoch from any snowflake ID

Functions

bucket(units, unit_type)
bucket(integer, atom) :: integer

When no id is provided, we generate a bucket for the current time

bucket(units, unit_type, id)
bucket(integer, atom, integer) :: integer

Get bucket value based on segments of N days

first_snowflake_for_timestamp(timestamp)
first_snowflake_for_timestamp(integer) :: integer

First Snowflake for timestamp, useful if you have a timestamp and want to find snowflakes before or after a certain millesecond

real_timestamp_of_id(id)
real_timestamp_of_id(integer) :: integer

Get timestamp from computer epoch - January 1, 1970, Midnight

timestamp_of_id(id)
timestamp_of_id(integer) :: integer

Get timestamp in ms from your config epoch from any snowflake ID