xref: /PHP-8.2/ext/date/tests/bug52808.phpt (revision c8a6a8ab)
1--TEST--
2Bug #52808 (Segfault when specifying interval as two dates)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Oslo');
6$intervals = array(
7    "2008-05-11T15:30:00Z/2007-03-01T13:00:00Z",
8    "2007-05-11T15:30:00Z/2008-03-01T13:00:00Z",
9    "2007-05-11T15:30:00Z 2008-03-01T13:00:00Z",
10    "2007-05-11T15:30:00Z/",
11    "2007-05-11T15:30:00Z",
12    "2007-05-11T15:30:00Z/:00Z",
13);
14foreach($intervals as $iv) {
15    try
16    {
17        $di = new DateInterval($iv);
18        var_dump($di);
19    }
20    catch ( Exception $e )
21    {
22        echo $e->getMessage(), "\n";
23    }
24}
25echo "==DONE==\n";
26?>
27--EXPECTF--
28object(DateInterval)#%d (%d) {
29  ["y"]=>
30  int(1)
31  ["m"]=>
32  int(2)
33  ["d"]=>
34  int(10)
35  ["h"]=>
36  int(2)
37  ["i"]=>
38  int(30)
39  ["s"]=>
40  int(0)
41  ["f"]=>
42  float(0)
43  ["invert"]=>
44  int(1)
45  ["days"]=>
46  int(437)
47  ["from_string"]=>
48  bool(false)
49}
50object(DateInterval)#%d (%d) {
51  ["y"]=>
52  int(0)
53  ["m"]=>
54  int(9)
55  ["d"]=>
56  int(18)
57  ["h"]=>
58  int(21)
59  ["i"]=>
60  int(30)
61  ["s"]=>
62  int(0)
63  ["f"]=>
64  float(0)
65  ["invert"]=>
66  int(0)
67  ["days"]=>
68  int(294)
69  ["from_string"]=>
70  bool(false)
71}
72object(DateInterval)#%d (%d) {
73  ["y"]=>
74  int(0)
75  ["m"]=>
76  int(9)
77  ["d"]=>
78  int(18)
79  ["h"]=>
80  int(21)
81  ["i"]=>
82  int(30)
83  ["s"]=>
84  int(0)
85  ["f"]=>
86  float(0)
87  ["invert"]=>
88  int(0)
89  ["days"]=>
90  int(294)
91  ["from_string"]=>
92  bool(false)
93}
94Failed to parse interval (2007-05-11T15:30:00Z/)
95Failed to parse interval (2007-05-11T15:30:00Z)
96Unknown or bad format (2007-05-11T15:30:00Z/:00Z)
97==DONE==
98