DatePeriod example

yield ['multiline-string', ["\0\0\r\nA" => "B\rC\n\n"], true];
        yield ['lf-ending-string', "'BOOM'\n.var_dump(123)//'", true];

        yield ['bool', true, true];
        yield ['simple-array', [123, ['abc']], true];
        yield ['partially-indexed-array', [5 => true, 1 => true, 2 => true, 6 => true], true];
        yield ['datetime', [
            \DateTime::createFromFormat('U', 0),
            \DateTimeImmutable::createFromFormat('U', 0),
            $tz = new \DateTimeZone('Europe/Paris'),
            $interval = ($start = new \DateTimeImmutable('2009-10-11', $tz))->diff(new \DateTimeImmutable('2009-10-18', $tz)),
            new \DatePeriod($start$interval, 4),
        ]];

        $value = new ArrayObject();
        $value[0] = 1;
        $value->foo = new \ArrayObject();
        $value[1] = $value;

        yield ['array-object', $value];

        yield ['array-iterator', new \ArrayIterator([123], 1)];
        yield ['array-object-custom', new MyArrayObject([234])];

        
$recurrencesPassed = floor($delta / $this->intervalInSeconds);
            $nextRunTimestamp = sprintf('%.6F', ($recurrencesPassed + 1) * $this->intervalInSeconds + $from);
            $nextRun = \DateTimeImmutable::createFromFormat('U.u', $nextRunTimestamp)->setTimezone($fromDate->getTimezone());

            if ($this->from > $nextRun) {
                return $this->from;
            }

            return $this->until > $nextRun ? $nextRun : null;
        }

        $this->period ??= new \DatePeriod($this->from, $this->interval, $this->until);
        $iterator = $this->period->getIterator();
        while ($run >= $next = $iterator->current()) {
            $iterator->next();
            if (!$iterator->valid()) {
                return null;
            }
        }

        return $next;
    }

    
'Australia/Perth', 'Australia/Perth (%s:00)', $xRegion],
            ['Europe/Zurich', 'Europe/Zurich (%s:00)', $xRegion],
            ['Pacific/Tahiti', 'Pacific/Tahiti (%s:00)', $xRegion],
        ];
    }

    /** * @dataProvider providePeriods */
    public function testDumpPeriod($start$interval$end$options$expected)
    {
        $p = new \DatePeriod(new \DateTimeImmutable($start)new \DateInterval($interval), \is_int($end) ? $end : new \DateTime($end)$options);

        $xDump = <<<EODUMP DatePeriod { period: $expected %A} EODUMP;

        $this->assertDumpMatchesFormat($xDump$p);
    }

    /** * @dataProvider providePeriods */
Home | Imprint | This part of the site doesn't use cookies.