mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-23 17:28:59 +03:00
Support version 6 UUIDs
See the following: * https://github.com/uuid6/uuid6-ietf-draft * http://gh.peabody.io/uuidv6/
This commit is contained in:
+11
-2
@@ -125,12 +125,21 @@ final class Fields implements FieldsInterface
|
||||
|
||||
public function getTimestamp(): Hexadecimal
|
||||
{
|
||||
return new Hexadecimal(sprintf(
|
||||
$timestamp = sprintf(
|
||||
'%03x%04s%08s',
|
||||
hexdec($this->getTimeHiAndVersion()->toString()) & 0x0fff,
|
||||
$this->getTimeMid()->toString(),
|
||||
$this->getTimeLow()->toString()
|
||||
));
|
||||
);
|
||||
|
||||
// Put the timestamp into the correct order, if this is a v6 UUID.
|
||||
if ($this->getVersion() === Uuid::UUID_TYPE_PEABODY) {
|
||||
$timestamp = substr($timestamp, 7)
|
||||
. substr($timestamp, 3, 4)
|
||||
. substr($timestamp, 0, 3);
|
||||
}
|
||||
|
||||
return new Hexadecimal($timestamp);
|
||||
}
|
||||
|
||||
public function getVersion(): ?int
|
||||
|
||||
Reference in New Issue
Block a user