Skip to content

Commit 517128f

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Match next run timezone with from timezone
2 parents f128a58 + 024ba81 commit 517128f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
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
@@ -36,7 +36,7 @@ public function testConstructor(PeriodicalTrigger $trigger, bool $optimizable =
3636

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getNextRunDate(\DateTimeImmutable $run): ?\DateTimeImmutable
102102
$delta = $run->format('U.u') - $from;
103103
$recurrencesPassed = floor($delta / $this->intervalInSeconds);
104104
$nextRunTimestamp = sprintf('%.6F', ($recurrencesPassed + 1) * $this->intervalInSeconds + $from);
105-
$nextRun = \DateTimeImmutable::createFromFormat('U.u', $nextRunTimestamp, $fromDate->getTimezone());
105+
$nextRun = \DateTimeImmutable::createFromFormat('U.u', $nextRunTimestamp)->setTimezone($fromDate->getTimezone());
106106

107107
if ($this->from > $nextRun) {
108108
return $this->from;

0 commit comments

Comments
 (0)