Skip to content

Commit 0da0e17

Browse files
committed
make DateCaster tests timezone-agnostic
1 parent f086c02 commit 0da0e17

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Caster/DateCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste
9292
if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/74639
9393
foreach (clone $p as $i => $d) {
9494
if (self::PERIOD_LIMIT === $i) {
95-
$now = new \DateTimeImmutable();
95+
$now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
9696
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
9797
? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u')))
9898
: $p->recurrences - $i

Tests/Caster/DateCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ public function testDumpPeriod($start, $interval, $end, $options, $expected)
353353
*/
354354
public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates)
355355
{
356-
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end), $options);
356+
$p = new \DatePeriod(new \DateTime($start, new \DateTimeZone('UTC')), new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end, new \DateTimeZone('UTC')), $options);
357357
$stub = new Stub();
358358

359359
$cast = DateCaster::castPeriod($p, [], $stub, false, 0);

0 commit comments

Comments
 (0)