make DateCaster tests timezone-agnostic
This commit is contained in:
parent
a863e2fe8d
commit
bfef4546d3
@ -92,7 +92,7 @@ class DateCaster
|
|||||||
if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/74639
|
if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/74639
|
||||||
foreach (clone $p as $i => $d) {
|
foreach (clone $p as $i => $d) {
|
||||||
if (self::PERIOD_LIMIT === $i) {
|
if (self::PERIOD_LIMIT === $i) {
|
||||||
$now = new \DateTimeImmutable();
|
$now = new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
|
||||||
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
|
$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')))
|
? 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
|
: $p->recurrences - $i
|
||||||
|
@ -353,7 +353,7 @@ EODUMP;
|
|||||||
*/
|
*/
|
||||||
public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates)
|
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();
|
$stub = new Stub();
|
||||||
|
|
||||||
$cast = DateCaster::castPeriod($p, [], $stub, false, 0);
|
$cast = DateCaster::castPeriod($p, [], $stub, false, 0);
|
||||||
|
Reference in New Issue
Block a user