8000 minor #39892 [Uid] Clarify the format returned by getTime() (fancyweb) · symfony/symfony@2c8368f · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c8368f

Browse files
committed
minor #39892 [Uid] Clarify the format returned by getTime() (fancyweb)
This PR was merged into the 5.1 branch. Discussion ---------- [Uid] Clarify the format returned by getTime() | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - I think adding a comment to explain the returned format is useful here, especially for uuid since their "normal" epoch is not the unix epoch. Commits ------- c14c737 [Uid] Clarify the format returned by getTime()
2 parents b4ec36f + c14c737 commit 2c8368f

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/Symfony/Component/Uid/Ulid.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public function toBase32(): string
104104
return $this->uid;
105105
}
106106

107+
/**
108+
* @return float Seconds since the Unix epoch 1970-01-01 00:00:00
109+
*/
107110
public function getTime(): float
108111
{
109112
$time = strtr(substr($this->uid, 0, 10), 'ABCDEFGHJKMNPQRSTVWXYZ', 'abcdefghijklmnopqrstuv');

src/Symfony/Component/Uid/UuidV1.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public function __construct(string $uuid = null)
3131
}
3232
}
3333

34+
/**
35+
* @return float Seconds since the Unix epoch 1970-01-01 00:00:00
36+
*/
3437
public function getTime(): float
3538
{
3639
$time = '0'.substr($this->uid, 15, 3).substr($this->uid, 9, 4).substr($this->uid, 0, 8);

src/Symfony/Component/Uid/UuidV6.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function __construct(string $uuid = null)
3232
}
3333
}
3434

35+
/**
36+
* @return float Seconds since the Unix epoch 1970-01-01 00:00:00
37+
*/
3538
public function getTime(): float
3639
{
3740
$time = '0'.substr($this->uid, 0, 8).substr($this->uid, 9, 4).substr($this->uid, 15, 3);

0 commit comments

Comments
 (0)
0