[−][src]Function epochs::uuid_v1
pub fn uuid_v1(num: i64) -> Option<NaiveDateTime>
UUID version 1 time (RFC 4122) is the number of hectonanoseconds (100 ns) since 1582-10-15, which is 12,219,292,800 seconds before the Unix epoch.
use epochs::uuid_v1; let ndt = uuid_v1(134_538_606_900_000_000).unwrap(); assert_eq!(ndt.to_string(), "2009-02-13 23:31:30");
UUIDs typically appear in "8-4-4-4-12" strings like
ca4892ce-4f7d-11ea-b77f-2e728ce88125
where the timestamp portion is buried inside. This one is "2020-02-14 23:00:27.148155". That first 1,
ca4892ce-4f7d-11ea-b77f-2e728ce88125
means it's a version 1 UUID (other versions don't have timestamps in them), so it's appropriate to take these bytes,
ca4892ce-4f7d-11ea-b77f-2e728ce88125
make an integer, 0x1ea4f7dca4892ce, and perform the calculation in this module on it.
use epochs::uuid_v1; let ndt = uuid_v1(0x1ea4f7dca4892ce).unwrap(); assert_eq!(ndt.to_string(), "2020-02-14 23:00:27.148155");