Add version 6 UUID generation

This commit is contained in:
Feoramund
2024-06-22 18:21:31 -04:00
parent 525bfca4ef
commit 9866b54d59
3 changed files with 96 additions and 1 deletions
+19 -1
View File
@@ -99,7 +99,7 @@ variant :: proc "contextless" (id: Identifier) -> (variant: Variant_Type) #no_bo
}
/*
Get the clock sequence of a version 1 UUID.
Get the clock sequence of a version 1 or version 6 UUID.
Inputs:
- id: The identifier.
@@ -151,6 +151,24 @@ time_v1 :: proc "contextless" (id: Identifier) -> (timestamp: u64) {
return cast(u64)transmute(u64le)timestamp_octets
}
/*
Get the timestamp of a version 6 UUID.
Inputs:
- id: The identifier.
Returns:
- timestamp: The timestamp, in 100-nanosecond intervals since 1582-10-15.
*/
time_v6 :: proc "contextless" (id: Identifier) -> (timestamp: u64) {
temporary := transmute(u128be)id
timestamp |= cast(u64)(temporary & 0xFFFFFFFF_FFFF0000_00000000_00000000 >> 68)
timestamp |= cast(u64)(temporary & 0x00000000_00000FFF_00000000_00000000 >> 64)
return timestamp
}
/*
Get the timestamp of a version 7 UUID.