deserialize-uuid
v0.1.1
Published
extracts the timestamp from a version 1 UUID
Downloads
5
Readme
node-deserialize-uuid
extracts the timestamp from a version 1 UUID
install
npm install deserialize-uuid
use
pass it a uuid-compatible uuid string
require('deserialize-uuid')('0c1d16c8-5c6a-11e4-90cf-12313b0e448d')
returns
{
timestamp: <BigNum 136335499267479240>,
timestampUtc: 1414275126747
}
timestamp
is a BigNum for the integral value of the uuid's timestamp field (see RFC4122). timestampUtc is the difference in whole milliseconds between the moment that the timestamp field represents and the UNIX epoch. That means you can do new Date(timestampUtc)
.
Ideally it would also return the RFC4122 "node" and "clock sequence" fields, but I haven't implemented this yet.