From bfef4546d313a12af364a1b9680f18f536f0be4f Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 27 Mar 2021 20:49:03 +0100 Subject: [PATCH] make DateCaster tests timezone-agnostic --- src/Symfony/Component/VarDumper/Caster/DateCaster.php | 2 +- src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/VarDumper/Caster/DateCaster.php b/src/Symfony/Component/VarDumper/Caster/DateCaster.php index 6b264c7958..171fbde55c 100644 --- a/src/Symfony/Component/VarDumper/Caster/DateCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DateCaster.php @@ -92,7 +92,7 @@ class DateCaster if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/74639 foreach (clone $p as $i => $d) { if (self::PERIOD_LIMIT === $i) { - $now = new \DateTimeImmutable(); + $now = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); $dates[] = sprintf('%s more', ($end = $p->getEndDate()) ? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u'))) : $p->recurrences - $i diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php index 7f36800d85..63be1681d0 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php @@ -353,7 +353,7 @@ EODUMP; */ public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates) { - $p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options); + $p = new \DatePeriod(new \DateTime($start, new \DateTimeZone('UTC')), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end, new \DateTimeZone('UTC')), $options); $stub = new Stub(); $cast = DateCaster::castPeriod($p, [], $stub, false, 0);