New UUIDs

It seems there are new UUID formats, two of which have timestamps in them!

Perl

A while back, I wrote is_epoch, a little tool to guess if a given string has a timestamp in it. It is written in Perl and comes with the Time::Moment::Epoch module (here is the motivation for that). I decided to add support for these new UUIDs.

Until now, only UUIDv1 contained a timestamp, so is_epoch ignored other UUIDs.

❯ # version 1 UUID-------v
❯ is_epoch 33c41a44-6cea-11e7-907b-a6006ad3dba0
2017-07-20T01:24:40.472634Z    (33c41a44-6cea-11e7-907b-a6006ad3dba0, uuid_v1, uuid_v1)

❯ # version 4 UUID-------v
❯ is_epoch 33c41a44-6cea-41e7-907b-a6006ad3dba0

The proposed UUIDv6 contains the same timestamp as UUIDv1, but the bits are in a different order.

❯ # version 6 UUID-------v
❯ is_epoch 1e76cea3-3c41-6a44-907b-a6006ad3dba0
2017-07-20T01:24:40.472634Z    (1e76cea3-3c41-6a44-907b-a6006ad3dba0, uuid_v6, uuid_v1)

The proposed UUIDv7 contains a java timestamp (Unix time in milliseconds).

❯ # version 7 UUID-------v
❯ is_epoch 017F22E2-79B0-7CC3-98C4-DC0C0C07398F
2022-02-22T19:22:22Z	(017F22E2-79B0-7CC3-98C4-DC0C0C07398F, uuid_v7, java)

I found out about the new UUID timestamps from this issue in the ulid-rs Rust crate. I decided to add support for ULIDs to is_epoch also. They are also java timestamps.

❯ is_epoch 01FWHE4YDGFK1SHH6W1G60EECF
2022-02-22T19:22:22Z	(01FWHE4YDGFK1SHH6W1G60EECF, ulid, java)

Since UUIDv6 uses uuid_v1 timestamps and both UUIDv7 and ULID use java timestamps, no changes to the Time::Moment::Epoch Perl module were necessary; only the is_epoch binary was changed.

Rust

I made the analogous changes to epochs-cli, the similar Rust tool. I implemented that as a separate crate from the epochs library on which it depends. Similar to the Perl case, I made no changes to epochs, only to epochs-cli.

❯ epochs 33c41a44-6cea-11e7-907b-a6006ad3dba0 33c41a44-6cea-41e7-907b-a6006ad3dba0 1e76cea3-3c41-6a44-907b-a6006ad3dba0 017F22E2-79B0-7CC3-98C4-DC0C0C07398F 01FWHE4YDGFK1SHH6W1G60EECF

33c41a44-6cea-11e7-907b-a6006ad3dba0 Uuid
  uuid_v1 => 2017-07-20T01:24:40.472634

1e76cea3-3c41-6a44-907b-a6006ad3dba0 Uuid
  uuid_v6 => 2017-07-20T01:24:40.472634

017F22E2-79B0-7CC3-98C4-DC0C0C07398F Uuid
  uuid_v7 => 2022-02-22T19:22:22

01FWHE4YDGFK1SHH6W1G60EECF Ulid
  ulid => 2022-02-22T19:22:22

Others

There are similar libraries written in Elixir, Go, and PowerShell. I haven't written the command-line interface for those yet, so they don't require updating.