8000 Match next run timezone with from timezone · symfony/symfony@9baf427 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9baf427

Browse files
committed
Match next run timezone with from timezone
1 parent 1df143d commit 9baf427

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Symfony/Component/Scheduler/Tests/Trigger/PeriodicalTriggerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class PeriodicalTriggerTest extends TestCase
2323
*/
2424
public function testConstructor(PeriodicalTrigger $trigger, bool $optimizable = true)
2525
{
26-
$run = new \DateTimeImmutable('2922-02-22 13:34:00+00:00');
26+
$run = new \DateTimeImmutable('2922-02-22 12:34:00+00:00');
2727

28-
$this->assertSame('2922-02-23 13:34:00+00:00', $trigger->getNextRunDate($run)->format('Y-m-d H:i:sP'));
28+
$this->assertSame('2922-02-23 13:34:00+01:00', $trigger->getNextRunDate($run)->format('Y-m-d H:i:sP'));
2929

3030
if ($optimizable) {
3131
// test that we are using the fast algorithm for short period of time
@@ -37,7 +37,7 @@ public function testConstructor(PeriodicalTrigger $trigger, bool $optimizable =
3737

3838
public static function provideForConstructor(): iterable
3939
{
40-
$from = new \DateTimeImmutable($now = '2022-02-22 13:34:00+00:00');
40+
$from = new \DateTimeImmutable($now = '2022-02-22 13:34:00+01:00');
4141
$until = new \DateTimeImmutable($farFuture = '3000-01-01');
4242

4343
yield [new PeriodicalTrigger(86400, $from, $until)];

src/Symfony/Component/Scheduler/Trigger/PeriodicalTrigger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getNextRunDate(\DateTimeImmutable $run): ?\DateTimeImmutable
9797
$delta = $run->format('U.u') - $from;
9898
$recurrencesPassed = floor($delta / $this->intervalInSeconds);
9999
$nextRunTimestamp = sprintf('%.6F', ($recurrencesPassed + 1) * $this->intervalInSeconds + $from);
100-
$nextRun = \DateTimeImmutable::createFromFormat('U.u', $nextRunTimestamp, $fromDate->getTimezone());
100+
$nextRun = \DateTimeImmutable::createFromFormat('U.u', $nextRunTimestamp)->setTimezone($fromDate->getTimezone());
101101

102102
if ($this->from > $nextRun) {
103103
return $this->from;

0 commit comments

Comments
 (0)
0