Skip to content

Commit

Permalink
Merge pull request #14 from okvpn/fix/locale-format
Browse files Browse the repository at this point in the history
Ignore LC_NUMERIC format in sprintf
  • Loading branch information
vtsykun authored Mar 29, 2024
2 parents d6a0c64 + d80e48a commit d927ba4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Command/CronCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Middleware/CronMiddlewareEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ 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;
});

$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);
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/CronUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit d927ba4

Please sign in to comment.