1--TEST--
2Test bad ISO date formats passed to DatePeriod constructor
3--FILE--
4<?php
5
6try {
7    new DatePeriod("R4");
8} catch (Exception $e) {
9    echo $e::class, ': ', $e->getMessage(), "\n";
10}
11
12try {
13    DatePeriod::createFromISO8601String("R4");
14} catch (Exception $e) {
15    echo $e::class, ': ', $e->getMessage(), "\n";
16}
17
18try {
19    new DatePeriod("R4/2012-07-01T00:00:00Z");
20} catch (Exception $e) {
21    echo $e::class, ': ', $e->getMessage(), "\n";
22}
23
24try {
25    DatePeriod::createFromISO8601String("R4/2012-07-01T00:00:00Z");
26} catch (Exception $e) {
27    echo $e::class, ': ', $e->getMessage(), "\n";
28}
29
30try {
31    new DatePeriod("2012-07-01T00:00:00Z/P7D");
32} catch (Exception $e) {
33    echo $e::class, ': ', $e->getMessage(), "\n";
34}
35
36try {
37    DatePeriod::createFromISO8601String("2012-07-01T00:00:00Z/P7D");
38} catch (Exception $e) {
39    echo $e::class, ': ', $e->getMessage(), "\n";
40}
41
42?>
43--EXPECTF--
44Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
45DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must contain a start date, "R4" given
46DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain a start date, "R4" given
47
48Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
49DateMalformedPeriodStringException: DatePeriod::__construct(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
50DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): ISO interval must contain an interval, "R4/2012-07-01T00:00:00Z" given
51
52Deprecated: Calling DatePeriod::__construct(string $isostr, int $options = 0) is deprecated, use DatePeriod::createFromISO8601String() instead in %s on line %d
53DateMalformedPeriodStringException: DatePeriod::__construct(): Recurrence count must be greater or equal to 1 and lower than %d
54DateMalformedPeriodStringException: DatePeriod::createFromISO8601String(): Recurrence count must be greater or equal to 1 and lower than %d
55