| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
|
|
3 |
//
|
|
|
4 |
// +----------------------------------------------------------------------+
|
|
|
5 |
// | Copyright (c) 1997-2005 Daniel Convissor <danielc@php.net> |
|
|
|
6 |
// +----------------------------------------------------------------------+
|
|
|
7 |
// | This source file is subject to the New BSD license, That is bundled |
|
|
|
8 |
// | with this package in the file LICENSE, and is available through |
|
|
|
9 |
// | the world-wide-web at |
|
|
|
10 |
// | http://www.opensource.org/licenses/bsd-license.php |
|
|
|
11 |
// | If you did not receive a copy of the new BSDlicense and are unable |
|
|
|
12 |
// | to obtain it through the world-wide-web, please send a note to |
|
|
|
13 |
// | pear-dev@lists.php.net so we can mail you a copy immediately. |
|
|
|
14 |
// +----------------------------------------------------------------------+
|
|
|
15 |
// | Author: Daniel Convissor <danielc@php.net> |
|
|
|
16 |
// +----------------------------------------------------------------------+
|
|
|
17 |
/**
|
|
|
18 |
* Tests for the Date_Calc class
|
|
|
19 |
*
|
|
|
20 |
* Any individual tests that fail will have their name, expected result
|
|
|
21 |
* and actual result printed out. So seeing no output when executing
|
|
|
22 |
* this file is a good thing.
|
|
|
23 |
*
|
|
|
24 |
* Can be run via CLI or a web server.
|
|
|
25 |
*
|
|
|
26 |
* This test senses whether it is from an installation of PEAR::Date or if
|
|
|
27 |
* it's from CVS or a .tar file. If it's an installed version, use the
|
|
|
28 |
* installed version of Date_Calc. Otherwise, use the local development
|
|
|
29 |
* copy of Date_Calc.
|
|
|
30 |
*
|
|
|
31 |
* @category Date and Time
|
|
|
32 |
* @package Date
|
|
|
33 |
* @author Daniel Convissor <danielc@php.net>
|
|
|
34 |
* @copyright 2005 The PHP Group
|
|
|
35 |
* @license http://www.php.net/license/3_0.txt PHP License
|
|
|
36 |
* @version CVS: $Id: calc.php,v 1.8 2005/11/15 00:16:40 pajoye Exp $
|
|
|
37 |
* @link http://pear.php.net/package/Date
|
|
|
38 |
* @since File available since Release 1.5
|
|
|
39 |
*/
|
|
|
40 |
|
|
|
41 |
if ('@include_path@' != '@'.'include_path'.'@') {
|
|
|
42 |
ini_set('include_path', ini_get('include_path')
|
|
|
43 |
. PATH_SEPARATOR . '.'
|
|
|
44 |
);
|
|
|
45 |
} else {
|
|
|
46 |
ini_set('include_path', realpath(dirname(__FILE__) . '/../')
|
|
|
47 |
. PATH_SEPARATOR . '.' . PATH_SEPARATOR
|
|
|
48 |
. ini_get('include_path')
|
|
|
49 |
);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* Get the needed class
|
|
|
54 |
*/
|
|
|
55 |
require_once 'Date/Calc.php';
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* Compare the test result to the expected result
|
|
|
59 |
*
|
|
|
60 |
* If the test fails, echo out the results.
|
|
|
61 |
*
|
|
|
62 |
* @param mixed $expect the scalar or array you expect from the test
|
|
|
63 |
* @param mixed $actual the scalar or array results from the test
|
|
|
64 |
* @param string $test_name the name of the test
|
|
|
65 |
*
|
|
|
66 |
* @return void
|
|
|
67 |
*/
|
|
|
68 |
function compare($expect, $actual, $test_name) {
|
|
|
69 |
if (is_array($expect)) {
|
|
|
70 |
if (count(array_diff($actual, $expect))) {
|
|
|
71 |
echo "$test_name failed. Expect:\n";
|
|
|
72 |
print_r($expect);
|
|
|
73 |
echo "Actual:\n";
|
|
|
74 |
print_r($actual);
|
|
|
75 |
}
|
|
|
76 |
} else {
|
|
|
77 |
if ($expect != $actual) {
|
|
|
78 |
echo "$test_name failed. Expect: $expect. Actual: $actual\n";
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
if (php_sapi_name() != 'cli') {
|
|
|
84 |
echo "<pre>\n";
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
compare('20001122', Date_Calc::dateFormat(22, 11, 2000, '%Y%m%d'), 'dateFormat');
|
|
|
89 |
compare('20001122', Date_Calc::dateFormat('22', '11', '2000', '%Y%m%d'), 'dateFormat str');
|
|
|
90 |
|
|
|
91 |
compare('2001', Date_Calc::defaultCentury('1'), 'defaultCentury 1 str');
|
|
|
92 |
compare('2001', Date_Calc::defaultCentury(1), 'defaultCentury 1');
|
|
|
93 |
compare('1960', Date_Calc::defaultCentury(60), 'defaultCentury 2');
|
|
|
94 |
compare('2010', Date_Calc::defaultCentury(10), 'defaultCentury 3');
|
|
|
95 |
|
|
|
96 |
compare(2451871, Date_Calc::dateToDays('22', '11', '2000'), 'dateToDays str');
|
|
|
97 |
compare(2451871, Date_Calc::dateToDays(22, 11, 2000), 'dateToDays');
|
|
|
98 |
compare('20001122', Date_Calc::daysToDate(2451871), 'daysToDate');
|
|
|
99 |
|
|
|
100 |
compare('2000-47-3', Date_Calc::gregorianToISO('22', '11', '2000'), 'gregorianToISO str');
|
|
|
101 |
compare('2000-47-3', Date_Calc::gregorianToISO(22, 11, 2000), 'gregorianToISO');
|
|
|
102 |
compare(2451716.56767, Date_Calc::dateSeason('SUMMERSOLSTICE', 2000), 'dateSeason');
|
|
|
103 |
|
|
|
104 |
compare(date('Ymd'), Date_Calc::dateNow(), 'dateNow');
|
|
|
105 |
compare(date('Y'), Date_Calc::getYear(), 'getYear');
|
|
|
106 |
compare(date('m'), Date_Calc::getMonth(), 'getMonth');
|
|
|
107 |
compare(date('d'), Date_Calc::getDay(), 'getDay');
|
|
|
108 |
|
|
|
109 |
compare(327, Date_Calc::julianDate(22, 11, 2000), 'julianDate');
|
|
|
110 |
compare('November', Date_Calc::getMonthFullname(11), 'getMonthFullname');
|
|
|
111 |
compare('Nov', Date_Calc::getMonthAbbrname(11), 'getMonthAbbrname');
|
|
|
112 |
compare('Saturday', Date_Calc::getWeekdayFullname(1, 1, 2005), 'getWeekdayFullname');
|
|
|
113 |
compare('Sat', Date_Calc::getWeekdayAbbrname(1, 1, 2005), 'getWeekdayAbbrname');
|
|
|
114 |
compare(11, Date_Calc::getMonthFromFullName('November'), 'getMonthFromFullName');
|
|
|
115 |
|
|
|
116 |
compare(327, Date_Calc::julianDate('22', '11', '2000'), 'julianDate str');
|
|
|
117 |
compare('November', Date_Calc::getMonthFullname('11'), 'getMonthFullname str');
|
|
|
118 |
compare('Nov', Date_Calc::getMonthAbbrname('11'), 'getMonthAbbrname str');
|
|
|
119 |
compare('Saturday', Date_Calc::getWeekdayFullname('01', '01', '2005'), 'getWeekdayFullname str');
|
|
|
120 |
compare('Sat', Date_Calc::getWeekdayAbbrname('01', '01', '2005'), 'getWeekdayAbbrname str');
|
|
|
121 |
|
|
|
122 |
$exp = array(
|
|
|
123 |
'January',
|
|
|
124 |
'February',
|
|
|
125 |
'March',
|
|
|
126 |
'April',
|
|
|
127 |
'May',
|
|
|
128 |
'June',
|
|
|
129 |
'July',
|
|
|
130 |
'August',
|
|
|
131 |
'September',
|
|
|
132 |
'October',
|
|
|
133 |
'November',
|
|
|
134 |
'December'
|
|
|
135 |
);
|
|
|
136 |
compare($exp, Date_Calc::getMonthNames(), 'getMonthNames');
|
|
|
137 |
|
|
|
138 |
$exp = array(
|
|
|
139 |
'Monday',
|
|
|
140 |
'Tuesday',
|
|
|
141 |
'Wednesday',
|
|
|
142 |
'Thursday',
|
|
|
143 |
'Friday',
|
|
|
144 |
'Saturday',
|
|
|
145 |
'Sunday'
|
|
|
146 |
);
|
|
|
147 |
compare($exp, Date_Calc::getWeekDays(), 'getWeekDays');
|
|
|
148 |
|
|
|
149 |
compare(3, Date_Calc::dayOfWeek(22, 11, 2000), 'dayOfWeek');
|
|
|
150 |
compare(47, Date_Calc::weekOfYear(22, 11, 2000), 'weekOfYear');
|
|
|
151 |
compare(4, Date_Calc::quarterOfYear(22, 11, 2000), 'quarterOfYear');
|
|
|
152 |
|
|
|
153 |
compare(3, Date_Calc::dayOfWeek('22', '11', '2000'), 'dayOfWeek str');
|
|
|
154 |
compare(47, Date_Calc::weekOfYear('22', '11', '2000'), 'weekOfYear str');
|
|
|
155 |
compare(4, Date_Calc::quarterOfYear('22', '11', '2000'), 'quarterOfYear str');
|
|
|
156 |
|
|
|
157 |
compare(28, Date_Calc::daysInMonth(2, 1900), 'daysInMonth 1');
|
|
|
158 |
compare(29, Date_Calc::daysInMonth(2, 1996), 'daysInMonth 2');
|
|
|
159 |
compare(29, Date_Calc::daysInMonth(2, 2000), 'daysInMonth 3');
|
|
|
160 |
compare(28, Date_Calc::daysInMonth(2, 2001), 'daysInMonth 4');
|
|
|
161 |
compare(30, Date_Calc::daysInMonth(11, 2000), 'daysInMonth 5');
|
|
|
162 |
|
|
|
163 |
compare(28, Date_Calc::daysInMonth('02', 1900), 'daysInMonth 1 str');
|
|
|
164 |
compare(29, Date_Calc::daysInMonth('02', 1996), 'daysInMonth 2 str');
|
|
|
165 |
compare(29, Date_Calc::daysInMonth('02', 2000), 'daysInMonth 3 str');
|
|
|
166 |
compare(28, Date_Calc::daysInMonth('02', 2001), 'daysInMonth 4 str');
|
|
|
167 |
compare(30, Date_Calc::daysInMonth('11', '2000'), 'daysInMonth 5 str');
|
|
|
168 |
|
|
|
169 |
compare(5, Date_Calc::weeksInMonth(11, 2000), 'weeksInMonth');
|
|
|
170 |
compare(5, Date_Calc::weeksInMonth('11', '2000'), 'weeksInMonth str');
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
$exp = array(
|
|
|
174 |
'19000226',
|
|
|
175 |
'19000227',
|
|
|
176 |
'19000228',
|
|
|
177 |
'19000301',
|
|
|
178 |
'19000302',
|
|
|
179 |
'19000303',
|
|
|
180 |
'19000304',
|
|
|
181 |
);
|
|
|
182 |
compare($exp, Date_Calc::getCalendarWeek(27, 2, 1900), 'getCalendarWeek 1');
|
|
|
183 |
|
|
|
184 |
$exp = array(
|
|
|
185 |
'20000228',
|
|
|
186 |
'20000229',
|
|
|
187 |
'20000301',
|
|
|
188 |
'20000302',
|
|
|
189 |
'20000303',
|
|
|
190 |
'20000304',
|
|
|
191 |
'20000305',
|
|
|
192 |
);
|
|
|
193 |
compare($exp, Date_Calc::getCalendarWeek(28, 2, 2000), 'getCalendarWeek 2');
|
|
|
194 |
|
|
|
195 |
$exp = array(
|
|
|
196 |
'20001127',
|
|
|
197 |
'20001128',
|
|
|
198 |
'20001129',
|
|
|
199 |
'20001130',
|
|
|
200 |
'20001201',
|
|
|
201 |
'20001202',
|
|
|
202 |
'20001203'
|
|
|
203 |
);
|
|
|
204 |
compare($exp, Date_Calc::getCalendarWeek(27, 11, 2000), 'getCalendarWeek 3');
|
|
|
205 |
compare($exp, Date_Calc::getCalendarWeek('27', '11', '2000'), 'getCalendarWeek 3 str');
|
|
|
206 |
|
|
|
207 |
$exp = array(
|
|
|
208 |
array(
|
|
|
209 |
'20001030',
|
|
|
210 |
'20001031',
|
|
|
211 |
'20001101',
|
|
|
212 |
'20001102',
|
|
|
213 |
'20001103',
|
|
|
214 |
'20001104',
|
|
|
215 |
),
|
|
|
216 |
array(
|
|
|
217 |
'20001105',
|
|
|
218 |
'20001106',
|
|
|
219 |
'20001107',
|
|
|
220 |
'20001108',
|
|
|
221 |
'20001109',
|
|
|
222 |
'20001110',
|
|
|
223 |
'20001111',
|
|
|
224 |
),
|
|
|
225 |
array(
|
|
|
226 |
'20001112',
|
|
|
227 |
'20001113',
|
|
|
228 |
'20001114',
|
|
|
229 |
'20001115',
|
|
|
230 |
'20001116',
|
|
|
231 |
'20001117',
|
|
|
232 |
'20001118',
|
|
|
233 |
),
|
|
|
234 |
array(
|
|
|
235 |
'20001119',
|
|
|
236 |
'20001121',
|
|
|
237 |
'20001122',
|
|
|
238 |
'20001123',
|
|
|
239 |
'20001124',
|
|
|
240 |
'20001125',
|
|
|
241 |
'20001126',
|
|
|
242 |
),
|
|
|
243 |
array(
|
|
|
244 |
'20001127',
|
|
|
245 |
'20001128',
|
|
|
246 |
'20001129',
|
|
|
247 |
'20001130',
|
|
|
248 |
'20001201',
|
|
|
249 |
'20001202',
|
|
|
250 |
'20001203'
|
|
|
251 |
)
|
|
|
252 |
);
|
|
|
253 |
compare($exp, Date_Calc::getCalendarMonth(11, 2000), 'getCalendarMonth');
|
|
|
254 |
compare($exp, Date_Calc::getCalendarMonth('11', '2000'), 'getCalendarMonth str');
|
|
|
255 |
|
|
|
256 |
// I don't feel like dealing with this right now...
|
|
|
257 |
//compare('', Date_Calc::getCalendarYear(2000), 'getCalendarYear');
|
|
|
258 |
|
|
|
259 |
compare('20001121', Date_Calc::prevDay(22, 11, 2000), 'prevDay');
|
|
|
260 |
compare('20001123', Date_Calc::nextDay(22, 11, 2000), 'nextDay');
|
|
|
261 |
compare('20001121', Date_Calc::prevDay(22, 11, 2000), 'prevDay str');
|
|
|
262 |
compare('20001123', Date_Calc::nextDay('22', '11', '2000'), 'nextDay str');
|
|
|
263 |
|
|
|
264 |
compare('20001117', Date_Calc::prevWeekday('19', '11', '2000'), 'prevWeekday 1 str');
|
|
|
265 |
compare('20001117', Date_Calc::prevWeekday(19, 11, 2000), 'prevWeekday 1');
|
|
|
266 |
compare('20001121', Date_Calc::prevWeekday(22, 11, 2000), 'prevWeekday 2');
|
|
|
267 |
compare('20001123', Date_Calc::nextWeekday(22, 11, 2000), 'nextWeekday 1');
|
|
|
268 |
compare('20001127', Date_Calc::nextWeekday(24, 11, 2000), 'nextWeekday 2');
|
|
|
269 |
compare('20001127', Date_Calc::nextWeekday('24', '11', '2000'), 'nextWeekday 2 str');
|
|
|
270 |
|
|
|
271 |
compare('20001121', Date_Calc::prevDayOfWeek('2', '22', '11', '2000'), 'prevDayOfWeek 1 str');
|
|
|
272 |
compare('20001121', Date_Calc::prevDayOfWeek(2, 22, 11, 2000), 'prevDayOfWeek 1');
|
|
|
273 |
compare('20001115', Date_Calc::prevDayOfWeek(3, 22, 11, 2000), 'prevDayOfWeek 2');
|
|
|
274 |
compare('20001122', Date_Calc::prevDayOfWeek(3, 22, 11, 2000, '%Y%m%d', true), 'prevDayOfWeek 3');
|
|
|
275 |
compare('20001122', Date_Calc::nextDayOfWeek(3, 22, 11, 2000, '%Y%m%d', true), 'nextDayOfWeek 1');
|
|
|
276 |
compare('20001129', Date_Calc::nextDayOfWeek(3, 22, 11, 2000), 'nextDayOfWeek 2');
|
|
|
277 |
compare('20001123', Date_Calc::nextDayOfWeek(4, 22, 11, 2000), 'nextDayOfWeek 3');
|
|
|
278 |
compare('20001123', Date_Calc::nextDayOfWeek('4', '22', '11', '2000'), 'nextDayOfWeek 3 str');
|
|
|
279 |
|
|
|
280 |
compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore('2', '22', '11', '2000'), 'prevDayOfWeekOnOrBefore 1 str');
|
|
|
281 |
compare('20001121', Date_Calc::prevDayOfWeekOnOrBefore(2, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 1');
|
|
|
282 |
compare('20001122', Date_Calc::prevDayOfWeekOnOrBefore(3, 22, 11, 2000), 'prevDayOfWeekOnOrBefore 2');
|
|
|
283 |
compare('20001122', Date_Calc::nextDayOfWeekOnOrAfter(3, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 1');
|
|
|
284 |
compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter(4, 22, 11, 2000), 'nextDayOfWeekOnOrAfter 2');
|
|
|
285 |
compare('20001123', Date_Calc::nextDayOfWeekOnOrAfter('4', '22', '11', '2000'), 'nextDayOfWeekOnOrAfter 2 str');
|
|
|
286 |
|
|
|
287 |
compare('20001120', Date_Calc::beginOfWeek('22', '11', '2000'), 'beginOfWeek str');
|
|
|
288 |
compare('20001120', Date_Calc::beginOfWeek(22, 11, 2000), 'beginOfWeek');
|
|
|
289 |
compare('20001126', Date_Calc::endOfWeek(22, 11, 2000), 'endOfWeek');
|
|
|
290 |
compare('20001126', Date_Calc::endOfWeek('22', '11', '2000'), 'endOfWeek str');
|
|
|
291 |
|
|
|
292 |
compare('20001113', Date_Calc::beginOfPrevWeek(22, 11, 2000), 'beginOfPrevWeek');
|
|
|
293 |
compare('20001127', Date_Calc::beginOfNextWeek(22, 11, 2000), 'beginOfNextWeek');
|
|
|
294 |
compare('20001113', Date_Calc::beginOfPrevWeek('22', '11', '2000'), 'beginOfPrevWeek str');
|
|
|
295 |
compare('20001127', Date_Calc::beginOfNextWeek('22', '11', '2000'), 'beginOfNextWeek str');
|
|
|
296 |
|
|
|
297 |
compare('20001101', Date_Calc::beginOfMonth(11, 2000), 'beginOfMonth');
|
|
|
298 |
compare('20001101', Date_Calc::beginOfMonth('11', '2000'), 'beginOfMonth str');
|
|
|
299 |
|
|
|
300 |
compare('20001001', Date_Calc::beginOfPrevMonth(22, 11, 2000), 'beginOfPrevMonth');
|
|
|
301 |
compare('20001031', Date_Calc::endOfPrevMonth(22, 11, 2000), 'endOfPrevMonth');
|
|
|
302 |
compare('20001001', Date_Calc::beginOfPrevMonth('22', '11', '2000'), 'beginOfPrevMonth str');
|
|
|
303 |
compare('20001031', Date_Calc::endOfPrevMonth('22', '11', '2000'), 'endOfPrevMonth str');
|
|
|
304 |
|
|
|
305 |
compare('20001201', Date_Calc::beginOfNextMonth(22, 11, 2000), 'beginOfNextMonth');
|
|
|
306 |
compare('20001231', Date_Calc::endOfNextMonth(22, 11, 2000), 'endOfNextMonth');
|
|
|
307 |
compare('20001201', Date_Calc::beginOfNextMonth('22', '11', '2000'), 'beginOfNextMonth str');
|
|
|
308 |
compare('20001231', Date_Calc::endOfNextMonth('22', '11', '2000'), 'endOfNextMonth str');
|
|
|
309 |
|
|
|
310 |
compare('19991001', Date_Calc::beginOfMonthBySpan(-13, 11, 2000), 'beginOfMonthBySpan 1');
|
|
|
311 |
compare('20001001', Date_Calc::beginOfMonthBySpan(-1, 11, 2000), 'beginOfMonthBySpan 2');
|
|
|
312 |
compare('20001101', Date_Calc::beginOfMonthBySpan(0, 11, 2000), 'beginOfMonthBySpan 3');
|
|
|
313 |
compare('20001201', Date_Calc::beginOfMonthBySpan(1, 11, 2000), 'beginOfMonthBySpan 4');
|
|
|
314 |
compare('20011201', Date_Calc::beginOfMonthBySpan(13, 11, 2000), 'beginOfMonthBySpan 5');
|
|
|
315 |
|
|
|
316 |
compare('19990101', Date_Calc::beginOfMonthBySpan('-13', '02', '2000'), 'beginOfMonthBySpan 6 str');
|
|
|
317 |
compare('19990101', Date_Calc::beginOfMonthBySpan(-13, 2, 2000), 'beginOfMonthBySpan 6');
|
|
|
318 |
compare('20000101', Date_Calc::beginOfMonthBySpan(-1, 2, 2000), 'beginOfMonthBySpan 7');
|
|
|
319 |
compare('20000201', Date_Calc::beginOfMonthBySpan(0, 2, 2000), 'beginOfMonthBySpan 8');
|
|
|
320 |
compare('20000301', Date_Calc::beginOfMonthBySpan(1, 2, 2000), 'beginOfMonthBySpan 9');
|
|
|
321 |
compare('20010301', Date_Calc::beginOfMonthBySpan(13, 2, 2000), 'beginOfMonthBySpan 10');
|
|
|
322 |
compare('20010301', Date_Calc::beginOfMonthBySpan('13', '02', '2000'), 'beginOfMonthBySpan 10 str');
|
|
|
323 |
|
|
|
324 |
compare('19991031', Date_Calc::endOfMonthBySpan(-13, 11, 2000), 'endOfMonthBySpan 1');
|
|
|
325 |
compare('20001031', Date_Calc::endOfMonthBySpan(-1, 11, 2000), 'endOfMonthBySpan 2');
|
|
|
326 |
compare('20001130', Date_Calc::endOfMonthBySpan(0, 11, 2000), 'endOfMonthBySpan 3');
|
|
|
327 |
compare('20001231', Date_Calc::endOfMonthBySpan(1, 11, 2000), 'endOfMonthBySpan 4');
|
|
|
328 |
compare('20011231', Date_Calc::endOfMonthBySpan(13, 11, 2000), 'endOfMonthBySpan 5');
|
|
|
329 |
|
|
|
330 |
compare('19990131', Date_Calc::endOfMonthBySpan('-13', '02', '2000'), 'endOfMonthBySpan 6 str');
|
|
|
331 |
compare('19990131', Date_Calc::endOfMonthBySpan(-13, 2, 2000), 'endOfMonthBySpan 6');
|
|
|
332 |
compare('20000131', Date_Calc::endOfMonthBySpan(-1, 2, 2000), 'endOfMonthBySpan 7');
|
|
|
333 |
compare('20000229', Date_Calc::endOfMonthBySpan(0, 2, 2000), 'endOfMonthBySpan 8');
|
|
|
334 |
compare('20000331', Date_Calc::endOfMonthBySpan(1, 2, 2000), 'endOfMonthBySpan 9');
|
|
|
335 |
compare('20010331', Date_Calc::endOfMonthBySpan(13, 2, 2000), 'endOfMonthBySpan 10');
|
|
|
336 |
compare('20010331', Date_Calc::endOfMonthBySpan('13', '02', '2000'), 'endOfMonthBySpan 10 str');
|
|
|
337 |
|
|
|
338 |
compare(3, Date_Calc::firstOfMonthWeekday(11, 2000), 'firstOfMonthWeekday');
|
|
|
339 |
compare(3, Date_Calc::firstOfMonthWeekday('11', '2000'), 'firstOfMonthWeekday str');
|
|
|
340 |
|
|
|
341 |
compare('20050101', Date_Calc::NWeekdayOfMonth(1, 6, 1, 2005), 'NWeekdayOfMonth 161');
|
|
|
342 |
compare('20050102', Date_Calc::NWeekdayOfMonth(1, 0, 1, 2005), 'NWeekdayOfMonth 101');
|
|
|
343 |
compare('20050103', Date_Calc::NWeekdayOfMonth(1, 1, 1, 2005), 'NWeekdayOfMonth 111');
|
|
|
344 |
compare('20050104', Date_Calc::NWeekdayOfMonth(1, 2, 1, 2005), 'NWeekdayOfMonth 121');
|
|
|
345 |
compare('20050105', Date_Calc::NWeekdayOfMonth(1, 3, 1, 2005), 'NWeekdayOfMonth 131');
|
|
|
346 |
compare('20050106', Date_Calc::NWeekdayOfMonth(1, 4, 1, 2005), 'NWeekdayOfMonth 141');
|
|
|
347 |
compare('20050107', Date_Calc::NWeekdayOfMonth(1, 5, 1, 2005), 'NWeekdayOfMonth 151');
|
|
|
348 |
|
|
|
349 |
compare('20050108', Date_Calc::NWeekdayOfMonth('2', '6', '01', '2005'), 'NWeekdayOfMonth 261');
|
|
|
350 |
compare('20050109', Date_Calc::NWeekdayOfMonth('2', '0', '01', '2005'), 'NWeekdayOfMonth 201');
|
|
|
351 |
compare('20050110', Date_Calc::NWeekdayOfMonth('2', '1', '01', '2005'), 'NWeekdayOfMonth 211');
|
|
|
352 |
compare('20050111', Date_Calc::NWeekdayOfMonth('2', '2', '01', '2005'), 'NWeekdayOfMonth 221');
|
|
|
353 |
compare('20050112', Date_Calc::NWeekdayOfMonth('2', '3', '01', '2005'), 'NWeekdayOfMonth 231');
|
|
|
354 |
compare('20050113', Date_Calc::NWeekdayOfMonth('2', '4', '01', '2005'), 'NWeekdayOfMonth 241');
|
|
|
355 |
compare('20050114', Date_Calc::NWeekdayOfMonth('2', '5', '01', '2005'), 'NWeekdayOfMonth 251');
|
|
|
356 |
|
|
|
357 |
compare('20050131', Date_Calc::NWeekdayOfMonth('last', 1, 1, 2005), 'NWeekdayOfMonth l11');
|
|
|
358 |
compare('20050130', Date_Calc::NWeekdayOfMonth('last', 0, 1, 2005), 'NWeekdayOfMonth l01');
|
|
|
359 |
compare('20050129', Date_Calc::NWeekdayOfMonth('last', 6, 1, 2005), 'NWeekdayOfMonth l61');
|
|
|
360 |
compare('20050128', Date_Calc::NWeekdayOfMonth('last', 5, 1, 2005), 'NWeekdayOfMonth l51');
|
|
|
361 |
compare('20050127', Date_Calc::NWeekdayOfMonth('last', 4, 1, 2005), 'NWeekdayOfMonth l41');
|
|
|
362 |
compare('20050126', Date_Calc::NWeekdayOfMonth('last', 3, 1, 2005), 'NWeekdayOfMonth l31');
|
|
|
363 |
compare('20050125', Date_Calc::NWeekdayOfMonth('last', 2, 1, 2005), 'NWeekdayOfMonth l21');
|
|
|
364 |
|
|
|
365 |
compare('20050331', Date_Calc::NWeekdayOfMonth('last', 4, 3, 2005), 'NWeekdayOfMonth l43');
|
|
|
366 |
compare('20050330', Date_Calc::NWeekdayOfMonth('last', 3, 3, 2005), 'NWeekdayOfMonth l33');
|
|
|
367 |
compare('20050329', Date_Calc::NWeekdayOfMonth('last', 2, 3, 2005), 'NWeekdayOfMonth l23');
|
|
|
368 |
compare('20050328', Date_Calc::NWeekdayOfMonth('last', 1, 3, 2005), 'NWeekdayOfMonth l13');
|
|
|
369 |
compare('20050327', Date_Calc::NWeekdayOfMonth('last', 0, 3, 2005), 'NWeekdayOfMonth l03');
|
|
|
370 |
compare('20050326', Date_Calc::NWeekdayOfMonth('last', 6, 3, 2005), 'NWeekdayOfMonth l63');
|
|
|
371 |
compare('20050325', Date_Calc::NWeekdayOfMonth('last', 5, 3, 2005), 'NWeekdayOfMonth l53');
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
compare(false, Date_Calc::isValidDate(29, 2, 1900), 'isValidDate 1');
|
|
|
375 |
compare(true, Date_Calc::isValidDate(29, 2, 2000), 'isValidDate 2');
|
|
|
376 |
compare(true, Date_Calc::isValidDate('29', '02', '2000'), 'isValidDate 2 str');
|
|
|
377 |
|
|
|
378 |
compare(false, Date_Calc::isLeapYear(1900), 'isLeapYear 1');
|
|
|
379 |
compare(true, Date_Calc::isLeapYear(1996), 'isLeapYear 2');
|
|
|
380 |
compare(true, Date_Calc::isLeapYear(2000), 'isLeapYear 3');
|
|
|
381 |
compare(false, Date_Calc::isLeapYear(2001), 'isLeapYear 4');
|
|
|
382 |
compare(false, Date_Calc::isLeapYear('2001'), 'isLeapYear 4 str');
|
|
|
383 |
|
|
|
384 |
compare(false, Date_Calc::isFutureDate('22', '11', '2000'), 'isFutureDate 1 str');
|
|
|
385 |
compare(false, Date_Calc::isFutureDate(22, 11, 2000), 'isFutureDate 1');
|
|
|
386 |
compare(true, Date_Calc::isFutureDate(22, 11, date('Y') + 1), 'isFutureDate 2');
|
|
|
387 |
|
|
|
388 |
compare(false, Date_Calc::isPastDate(22, 11, date('Y') + 1), 'isPastDate 1');
|
|
|
389 |
compare(true, Date_Calc::isPastDate(22, 11, 2000), 'isPastDate 2');
|
|
|
390 |
compare(true, Date_Calc::isPastDate('22', '11', '2000'), 'isPastDate 2 str');
|
|
|
391 |
|
|
|
392 |
compare(10, Date_Calc::dateDiff(22, 11, 2000, 12, 11, 2000), 'dateDiff 1');
|
|
|
393 |
compare(10, Date_Calc::dateDiff(12, 11, 2000, 22, 11, 2000), 'dateDiff 2');
|
|
|
394 |
compare(61, Date_Calc::dateDiff(22, 11, 2000, 22, 1, 2001), 'dateDiff 3');
|
|
|
395 |
compare(61, Date_Calc::dateDiff('22', '11', '2000', '22', '01', '2001'), 'dateDiff 3 str');
|
|
|
396 |
|
|
|
397 |
compare(-1, Date_Calc::compareDates(12, 11, 2000, 22, 11, 2000), 'compareDates 1');
|
|
|
398 |
compare(0, Date_Calc::compareDates(22, 11, 2000, 22, 11, 2000), 'compareDates 2');
|
|
|
399 |
compare(1, Date_Calc::compareDates(22, 11, 2000, 12, 11, 2000), 'compareDates 3');
|
|
|
400 |
compare(1, Date_Calc::compareDates('22', '11', '2000', '12', '11', '2000'), 'compareDates 3 str');
|