From d80e48aacf72524efc65fc3e7ccaaea59263b4bf Mon Sep 17 00:00:00 2001 From: Uladzimir Tsykun Date: Sat, 30 Mar 2024 00:17:14 +0100 Subject: [PATCH] Ignore LC_NUMERIC format in sprintf --- src/Command/CronCommand.php | 2 +- src/Middleware/CronMiddlewareEngine.php | 4 ++-- src/Utils/CronUtils.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Command/CronCommand.php b/src/Command/CronCommand.php index 481eaa8..e1004fd 100644 --- a/src/Command/CronCommand.php +++ b/src/Command/CronCommand.php @@ -99,7 +99,7 @@ protected function executeLoop(InputInterface $input, OutputInterface $output): } $this->scheduler($input, $output); - $output->writeln(sprintf('[%s] All schedule tasks completed in %.3f seconds', $this->getCurrentDate()->format('Y-m-d H:i:s.u'), \microtime(true) - $runAt), OutputInterface::VERBOSITY_VERBOSE); + $output->writeln(sprintf('[%s] All schedule tasks completed in %.3F seconds', $this->getCurrentDate()->format('Y-m-d H:i:s.u'), \microtime(true) - $runAt), OutputInterface::VERBOSITY_VERBOSE); if ($loop instanceof ReactLoopAdapter) { $loop->setDefaultLoopTime(); } diff --git a/src/Middleware/CronMiddlewareEngine.php b/src/Middleware/CronMiddlewareEngine.php index 2ac1d3b..7718c0a 100644 --- a/src/Middleware/CronMiddlewareEngine.php +++ b/src/Middleware/CronMiddlewareEngine.php @@ -103,7 +103,7 @@ private function handleDemand(\DateTimeInterface $now, ScheduleEnvelope $envelop $delay = (float) $nextTime->format('U.u') - (float) $now->format('U.u'); $loop->addTimer($delay, $runner); - ET::debug($envelope, \sprintf("{{ task }} > was scheduled with delay %.6f sec.", $delay)); + ET::debug($envelope, \sprintf("{{ task }} > was scheduled with delay %.6F sec.", $delay)); } return $result; @@ -111,7 +111,7 @@ private function handleDemand(\DateTimeInterface $now, ScheduleEnvelope $envelop $delay = (float) $nextTime->format('U.u') - (float) $now->format('U.u'); - ET::debug($envelope, \sprintf("{{ task }} > was scheduled with delay %.6f sec.", $delay)); + ET::debug($envelope, \sprintf("{{ task }} > was scheduled with delay %.6F sec.", $delay)); $loop->addTimer($delay, $runner); return ($clone = clone $stack)->end()->handle($envelope, $clone); diff --git a/src/Utils/CronUtils.php b/src/Utils/CronUtils.php index 875f213..1b775c7 100644 --- a/src/Utils/CronUtils.php +++ b/src/Utils/CronUtils.php @@ -9,7 +9,7 @@ */ final class CronUtils { - public static function toDate(/*float|string|\DateTimeInterface */ $unix, /* \DateTimeInterface|\DateTimeZone|string|null */ $timezone): \DateTimeImmutable + public static function toDate(/*float|string|\DateTimeInterface */ $unix, /* \DateTimeInterface|\DateTimeZone|string|null */ $timezone = null): \DateTimeImmutable { $timezone = $timezone instanceof \DateTimeInterface ? $timezone->getTimezone() : $timezone; $timezone = \is_string($timezone) ? new \DateTimeZone($timezone) : $timezone; @@ -18,6 +18,6 @@ public static function toDate(/*float|string|\DateTimeInterface */ $unix, /* \Da $unix = $unix->format('U.u'); } - return \DateTimeImmutable::createFromFormat("U.u", sprintf("%.6f", $unix), $timezone); + return \DateTimeImmutable::createFromFormat("U.u", sprintf("%.6F", $unix), $timezone); } }