A 4-arity version of uuid1 which accepts a time parameter as either a 60-bit bitstring or a DateTime, allowing the caller to provide the timestamp for use in the generated UUID.
uuid1_gettime/1 which accepts a UUIDv1 (in any of the usual formats) and returns the embedded timestamp as a DateTime.
This is useful for me specifically because we use Cassandra and the UUIDv1s generated by this library are compatible with its timeuuid column type. Although Cassandra provides functions to extract timestamps from these timeuuids, there is no function to create a timeuuid from a timestamp, so I can't insert elements with a timestamp other than "now".
I added tests for the existing functionality that I touched as well as the newly added functionality.
This PR adds two new functions:
uuid1
which accepts atime
parameter as either a 60-bit bitstring or aDateTime
, allowing the caller to provide the timestamp for use in the generated UUID.uuid1_gettime/1
which accepts a UUIDv1 (in any of the usual formats) and returns the embedded timestamp as aDateTime
.This is useful for me specifically because we use Cassandra and the UUIDv1s generated by this library are compatible with its timeuuid column type. Although Cassandra provides functions to extract timestamps from these timeuuids, there is no function to create a timeuuid from a timestamp, so I can't insert elements with a timestamp other than "now".
I added tests for the existing functionality that I touched as well as the newly added functionality.
Thanks for this great library! :)