minor #40599 [VarDumper] make DateCaster tests timezone-agnostic (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[VarDumper] make DateCaster tests timezone-agnostic

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

bfef4546d3 make DateCaster tests timezone-agnostic
This commit is contained in:
Nyholm 2021-03-27 22:10:44 +01:00
commit 0d99f93eaf
No known key found for this signature in database
GPG Key ID: D6332DE2B6F8FA38
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);