make DateCaster tests timezone-agnostic

This commit is contained in:
Christian Flothmann 2021-03-27 20:49:03 +01:00
parent a863e2fe8d
commit bfef4546d3
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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);