1<?php
2
3/*
4 * Note: test names match method names in a set of PHPUnit tests
5 * in a userland package.  Please be so kind as to leave them.
6 */
7
8date_default_timezone_set('America/New_York');
9
10
11/*
12 * Check PHP bug 49081
13 */
14echo "test_bug_49081__1: ";
15examine_diff('2010-03-31', '2010-03-01', 'P+0Y0M30DT0H0M0S', 30);
16
17echo "test_bug_49081__2: ";
18examine_diff('2010-04-01', '2010-03-01', 'P+0Y1M0DT0H0M0S', 31);
19
20echo "test_bug_49081__3: ";
21examine_diff('2010-04-01', '2010-03-31', 'P+0Y0M1DT0H0M0S', 1);
22
23echo "test_bug_49081__4: ";
24examine_diff('2010-04-29', '2010-03-31', 'P+0Y0M29DT0H0M0S', 29);
25
26echo "test_bug_49081__5: ";
27examine_diff('2010-04-30', '2010-03-31', 'P+0Y0M30DT0H0M0S', 30);
28
29echo "test_bug_49081__6: ";
30examine_diff('2010-04-30', '2010-03-30', 'P+0Y1M0DT0H0M0S', 31);
31
32echo "test_bug_49081__7: ";
33examine_diff('2010-04-30', '2010-03-29', 'P+0Y1M1DT0H0M0S', 32);
34
35echo "test_bug_49081__8: ";
36examine_diff('2010-01-29', '2010-01-01', 'P+0Y0M28DT0H0M0S', 28);
37
38echo "test_bug_49081__9: ";
39examine_diff('2010-01-30', '2010-01-01', 'P+0Y0M29DT0H0M0S', 29);
40
41echo "test_bug_49081__10: ";
42examine_diff('2010-01-31', '2010-01-01', 'P+0Y0M30DT0H0M0S', 30);
43
44echo "test_bug_49081__11: ";
45examine_diff('2010-02-01', '2010-01-01', 'P+0Y1M0DT0H0M0S', 31);
46
47echo "test_bug_49081__12: ";
48examine_diff('2010-02-01', '2010-01-31', 'P+0Y0M1DT0H0M0S', 1);
49
50echo "test_bug_49081__13: ";
51examine_diff('2010-02-27', '2010-01-31', 'P+0Y0M27DT0H0M0S', 27);
52
53echo "test_bug_49081__14: ";
54examine_diff('2010-02-28', '2010-01-31', 'P+0Y0M28DT0H0M0S', 28);
55
56echo "test_bug_49081__15: ";
57examine_diff('2010-02-28', '2010-01-30', 'P+0Y0M29DT0H0M0S', 29);
58
59echo "test_bug_49081__16: ";
60examine_diff('2010-02-28', '2010-01-29', 'P+0Y0M30DT0H0M0S', 30);
61
62echo "test_bug_49081__17: ";
63examine_diff('2010-02-28', '2010-01-28', 'P+0Y1M0DT0H0M0S', 31);
64
65echo "test_bug_49081__18: ";
66examine_diff('2010-02-28', '2010-01-27', 'P+0Y1M1DT0H0M0S', 32);
67
68echo "test_bug_49081__19: ";
69examine_diff('2010-03-01', '2010-01-01', 'P+0Y2M0DT0H0M0S', 59);
70
71echo "test_bug_49081__20: ";
72examine_diff('2010-03-01', '2010-01-31', 'P+0Y0M29DT0H0M0S', 29);
73
74// NOTE: sub() produces different answer.
75echo "test_bug_49081__21: ";
76examine_diff('2010-03-27', '2010-01-31', 'P+0Y1M24DT0H0M0S', 55);
77
78// NOTE: sub() produces different answer.
79echo "test_bug_49081__22: ";
80examine_diff('2010-03-28', '2010-01-31', 'P+0Y1M25DT0H0M0S', 56);
81
82// NOTE: sub() produces different answer.
83echo "test_bug_49081__23: ";
84examine_diff('2010-03-29', '2010-01-31', 'P+0Y1M26DT0H0M0S', 57);
85
86// NOTE: sub() produces different answer.
87echo "test_bug_49081__24: ";
88examine_diff('2010-03-30', '2010-01-31', 'P+0Y1M27DT0H0M0S', 58);
89
90echo "test_bug_49081__25: ";
91examine_diff('2010-03-31', '2010-01-31', 'P+0Y2M0DT0H0M0S', 59);
92
93echo "test_bug_49081__26: ";
94examine_diff('2010-03-31', '2010-01-30', 'P+0Y2M1DT0H0M0S', 60);
95
96echo "test_bug_49081__27: ";
97examine_diff('2009-01-31', '2009-01-01', 'P+0Y0M30DT0H0M0S', 30);
98
99echo "test_bug_49081__28: ";
100examine_diff('2010-03-27', '2010-02-28', 'P+0Y0M27DT0H0M0S', 27);
101
102echo "test_bug_49081__29: ";
103examine_diff('2010-03-28', '2010-02-28', 'P+0Y1M0DT0H0M0S', 28);
104
105echo "test_bug_49081__30: ";
106examine_diff('2010-03-29', '2010-02-28', 'P+0Y1M1DT0H0M0S', 29);
107
108echo "test_bug_49081__31: ";
109examine_diff('2010-03-27', '2010-02-27', 'P+0Y1M0DT0H0M0S', 28);
110
111echo "test_bug_49081__32: ";
112examine_diff('2010-03-27', '2010-02-26', 'P+0Y1M1DT0H0M0S', 29);
113
114
115/*
116 * Check PHP bug 49081, negative
117 */
118echo "test_bug_49081_negative__1: ";
119examine_diff('2010-03-01', '2010-03-31', 'P-0Y0M30DT0H0M0S', 30);
120
121echo "test_bug_49081_negative__2: ";
122examine_diff('2010-03-01', '2010-04-01', 'P-0Y1M0DT0H0M0S', 31);
123
124echo "test_bug_49081_negative__3: ";
125examine_diff('2010-03-31', '2010-04-01', 'P-0Y0M1DT0H0M0S', 1);
126
127echo "test_bug_49081_negative__4: ";
128examine_diff('2010-03-31', '2010-04-29', 'P-0Y0M29DT0H0M0S', 29);
129
130echo "test_bug_49081_negative__5: ";
131examine_diff('2010-03-31', '2010-04-30', 'P-0Y0M30DT0H0M0S', 30);
132
133echo "test_bug_49081_negative__6: ";
134examine_diff('2010-03-30', '2010-04-30', 'P-0Y1M0DT0H0M0S', 31);
135
136echo "test_bug_49081_negative__7: ";
137examine_diff('2010-03-29', '2010-04-30', 'P-0Y1M1DT0H0M0S', 32);
138
139echo "test_bug_49081_negative__8: ";
140examine_diff('2010-01-01', '2010-01-29', 'P-0Y0M28DT0H0M0S', 28);
141
142echo "test_bug_49081_negative__9: ";
143examine_diff('2010-01-01', '2010-01-30', 'P-0Y0M29DT0H0M0S', 29);
144
145echo "test_bug_49081_negative__10: ";
146examine_diff('2010-01-01', '2010-01-31', 'P-0Y0M30DT0H0M0S', 30);
147
148echo "test_bug_49081_negative__11: ";
149examine_diff('2010-01-01', '2010-02-01', 'P-0Y1M0DT0H0M0S', 31);
150
151echo "test_bug_49081_negative__12: ";
152examine_diff('2010-01-31', '2010-02-01', 'P-0Y0M1DT0H0M0S', 1);
153
154echo "test_bug_49081_negative__13: ";
155examine_diff('2010-01-31', '2010-02-27', 'P-0Y0M27DT0H0M0S', 27);
156
157echo "test_bug_49081_negative__14: ";
158examine_diff('2010-01-31', '2010-02-28', 'P-0Y0M28DT0H0M0S', 28);
159
160echo "test_bug_49081_negative__15: ";
161examine_diff('2010-01-30', '2010-02-28', 'P-0Y0M29DT0H0M0S', 29);
162
163echo "test_bug_49081_negative__16: ";
164examine_diff('2010-01-29', '2010-02-28', 'P-0Y0M30DT0H0M0S', 30);
165
166echo "test_bug_49081_negative__17: ";
167examine_diff('2010-01-28', '2010-02-28', 'P-0Y1M0DT0H0M0S', 31);
168
169echo "test_bug_49081_negative__18: ";
170examine_diff('2010-01-27', '2010-02-28', 'P-0Y1M1DT0H0M0S', 32);
171
172echo "test_bug_49081_negative__19: ";
173examine_diff('2010-01-01', '2010-03-01', 'P-0Y2M0DT0H0M0S', 59);
174
175// NOTE: sub() produces different answer.
176echo "test_bug_49081_negative__20: ";
177examine_diff('2010-01-31', '2010-03-01', 'P-0Y1M1DT0H0M0S', 29);
178
179// NOTE: sub() produces different answer.
180echo "test_bug_49081_negative__21: ";
181examine_diff('2010-01-31', '2010-03-27', 'P-0Y1M27DT0H0M0S', 55);
182
183// NOTE: sub() produces different answer.
184echo "test_bug_49081_negative__22: ";
185examine_diff('2010-01-31', '2010-03-28', 'P-0Y1M28DT0H0M0S', 56);
186
187// NOTE: sub() produces different answer.
188echo "test_bug_49081_negative__23: ";
189examine_diff('2010-01-31', '2010-03-29', 'P-0Y1M29DT0H0M0S', 57);
190
191// NOTE: sub() produces different answer.
192echo "test_bug_49081_negative__24: ";
193examine_diff('2010-01-31', '2010-03-30', 'P-0Y1M30DT0H0M0S', 58);
194
195echo "test_bug_49081_negative__25: ";
196examine_diff('2010-01-31', '2010-03-31', 'P-0Y2M0DT0H0M0S', 59);
197
198echo "test_bug_49081_negative__26: ";
199examine_diff('2010-01-30', '2010-03-31', 'P-0Y2M1DT0H0M0S', 60);
200
201echo "test_bug_49081_negative__27: ";
202examine_diff('2009-01-01', '2009-01-31', 'P-0Y0M30DT0H0M0S', 30);
203
204echo "test_bug_49081_negative__28: ";
205examine_diff('2010-02-28', '2010-03-27', 'P-0Y0M27DT0H0M0S', 27);
206
207echo "test_bug_49081_negative__29: ";
208examine_diff('2010-02-28', '2010-03-28', 'P-0Y1M0DT0H0M0S', 28);
209
210echo "test_bug_49081_negative__30: ";
211examine_diff('2010-02-28', '2010-03-29', 'P-0Y1M1DT0H0M0S', 29);
212
213echo "test_bug_49081_negative__31: ";
214examine_diff('2010-02-27', '2010-03-27', 'P-0Y1M0DT0H0M0S', 28);
215
216echo "test_bug_49081_negative__32: ";
217examine_diff('2010-02-26', '2010-03-27', 'P-0Y1M1DT0H0M0S', 29);
218