mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Default to microtime() instead of DateTimeImmutable
This commit is contained in:
@@ -15,7 +15,6 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Generator;
|
||||
|
||||
use Brick\Math\BigInteger;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
|
||||
@@ -68,7 +67,12 @@ class UnixTimeGenerator implements TimeGeneratorInterface
|
||||
*/
|
||||
public function generate($node = null, ?int $clockSeq = null, ?DateTimeInterface $dateTime = null): string
|
||||
{
|
||||
$time = ($dateTime ?? new DateTimeImmutable('now'))->format('Uv');
|
||||
if ($dateTime === null) {
|
||||
$time = microtime(false);
|
||||
$time = substr($time, 11) . substr($time, 2, 3);
|
||||
} else {
|
||||
$time = $dateTime->format('Uv');
|
||||
}
|
||||
|
||||
if ($time > self::$time || ($dateTime !== null && $time !== self::$time)) {
|
||||
$this->randomize($time);
|
||||
|
||||
Reference in New Issue
Block a user