File tree 4 files changed +77
-1
lines changed
4 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ var_dump($e);
18
18
19
19
echo "\n\nCalling __serialize manually: \n" ;
20
20
var_dump ($ d ->__serialize ());
21
+
22
+ echo "\n\nUsed serialised interval: \n" ;
23
+ $ now = new DateTimeImmutable ("2022-04-22 16:25:11 BST " );
24
+ var_dump ($ now ->add ($ e ));
25
+ var_dump ($ now ->sub ($ e ));
21
26
?>
22
27
--EXPECTF--
23
28
Original object:
@@ -97,3 +102,22 @@ array(%d) {
97
102
["from_string"]=>
98
103
bool(false)
99
104
}
105
+
106
+
107
+ Used serialised interval:
108
+ object(DateTimeImmutable)#4 (3) {
109
+ ["date"]=>
110
+ string(26) "2024-04-26 22:33:11.000000"
111
+ ["timezone_type"]=>
112
+ int(2)
113
+ ["timezone"]=>
114
+ string(3) "BST"
115
+ }
116
+ object(DateTimeImmutable)#4 (3) {
117
+ ["date"]=>
118
+ string(26) "2020-04-18 10:17:11.000000"
119
+ ["timezone_type"]=>
120
+ int(2)
121
+ ["timezone"]=>
122
+ string(3) "BST"
123
+ }
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ $d->__unserialize(
37
37
]
38
38
);
39
39
var_dump ($ d );
40
+
41
+ echo "\n\nUsed serialised interval: \n" ;
42
+ $ now = new DateTimeImmutable ("2022-04-15 10:27:27 BST " );
43
+ var_dump ($ now ->add ($ e ));
44
+ var_dump ($ now ->sub ($ e ));
40
45
?>
41
46
--EXPECTF--
42
47
Original object:
@@ -141,3 +146,22 @@ object(DateInterval)#5 (10) {
141
146
["from_string"]=>
142
147
bool(false)
143
148
}
149
+
150
+
151
+ Used serialised interval:
152
+ object(DateTimeImmutable)#6 (3) {
153
+ ["date"]=>
154
+ string(26) "2065-08-08 11:39:54.000000"
155
+ ["timezone_type"]=>
156
+ int(2)
157
+ ["timezone"]=>
158
+ string(3) "BST"
159
+ }
160
+ object(DateTimeImmutable)#6 (3) {
161
+ ["date"]=>
162
+ string(26) "1978-12-22 09:15:00.000000"
163
+ ["timezone_type"]=>
164
+ int(2)
165
+ ["timezone"]=>
166
+ string(3) "BST"
167
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ Test DateInterval::__serialize and DateInterval::__unserialize
4
4
<?php
5
5
date_default_timezone_set ("Europe/London " );
6
6
7
+ // the 15:30 gets ignored, as it's not a "relative" interval.
8
+ // See: https://github.com/php/php-src/issues/8458
7
9
$ d = DateInterval::createFromDateString ('next weekday 15:30 ' );
8
10
echo "Original object: \n" ;
9
11
var_dump ($ d );
@@ -28,6 +30,11 @@ $d->__unserialize(
28
30
]
29
31
);
30
32
var_dump ($ d );
33
+
34
+ echo "\n\nUsed serialised interval: \n" ;
35
+ $ now = new DateTimeImmutable ("2022-04-22 16:25:11 BST " );
36
+ var_dump ($ now ->add ($ e ));
37
+ var_dump ($ now ->sub ($ e ));
31
38
?>
32
39
--EXPECTF--
33
40
Original object:
@@ -68,3 +75,24 @@ object(DateInterval)#3 (2) {
68
75
["date_string"]=>
69
76
string(18) "next weekday 15:30"
70
77
}
78
+
79
+
80
+ Used serialised interval:
81
+ object(DateTimeImmutable)#4 (3) {
82
+ ["date"]=>
83
+ string(26) "2022-04-25 16:25:11.000000"
84
+ ["timezone_type"]=>
85
+ int(2)
86
+ ["timezone"]=>
87
+ string(3) "BST"
88
+ }
89
+
90
+ Warning: DateTimeImmutable::sub(): Only non-special relative time specifications are supported for subtraction in %s on line %d
91
+ object(DateTimeImmutable)#4 (3) {
92
+ ["date"]=>
93
+ string(26) "2022-04-22 16:25:11.000000"
94
+ ["timezone_type"]=>
95
+ int(2)
96
+ ["timezone"]=>
97
+ string(3) "BST"
98
+ }
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ object(DateInterval)#%d (%d) {
56
56
bool(false)
57
57
}
58
58
string(164) "O:12:"DateInterval":10:{s:1:"y";i:0;s:1:"m";i:0;s:1:"d";i:0;s:1:"h";i:4;s:1:"i";i:0;s:1:"s";i:0;s:1:"f";d:0;s:6:"invert";i:0;s:4:"days";i:0;s:11:"from_string";b:0;}"
59
- DateInterval::__set_state(array(
59
+ \ DateInterval::__set_state(array(
60
60
'y' => 0,
61
61
'm' => 0,
62
62
'd' => 0,
You can’t perform that action at this time.
0 commit comments