xref: /PHP-8.2/ext/date/tests/bug61642.phpt (revision f8d79582)
1--TEST--
2Bug #61642 (modify("+5 weekdays") returns Sunday)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7// ±5 and ±10 (and any non-zero multiple of 5) is broken, but everything else
8// should already work correctly.
9$weekdays = range(-11, 11);
10$dates = array('2012-03-29', '2012-03-30', '2012-03-31', '2012-04-01', '2012-04-02', '2012-04-03', '2012-04-04', '2012-04-05');
11
12$header = array();
13
14foreach ($dates as $startdate) {
15    $date = new DateTime($startdate);
16
17    $header[] = $date->format('Y-m-d D');
18}
19
20echo '###  ', implode('  ', $header), "\n\n";
21
22foreach ($weekdays as $days) {
23    $line = array();
24
25    printf('%+3d  ', $days);
26
27    foreach ($dates as $startdate) {
28        $date = new DateTime($startdate);
29        $date->modify("{$days} weekdays");
30
31        $line[] = $date->format('Y-m-d D');
32    }
33
34    echo implode('  ', $line), "\n";
35}
36?>
37--EXPECT--
38###  2012-03-29 Thu  2012-03-30 Fri  2012-03-31 Sat  2012-04-01 Sun  2012-04-02 Mon  2012-04-03 Tue  2012-04-04 Wed  2012-04-05 Thu
39
40-11  2012-03-14 Wed  2012-03-15 Thu  2012-03-16 Fri  2012-03-16 Fri  2012-03-16 Fri  2012-03-19 Mon  2012-03-20 Tue  2012-03-21 Wed
41-10  2012-03-15 Thu  2012-03-16 Fri  2012-03-19 Mon  2012-03-19 Mon  2012-03-19 Mon  2012-03-20 Tue  2012-03-21 Wed  2012-03-22 Thu
42 -9  2012-03-16 Fri  2012-03-19 Mon  2012-03-20 Tue  2012-03-20 Tue  2012-03-20 Tue  2012-03-21 Wed  2012-03-22 Thu  2012-03-23 Fri
43 -8  2012-03-19 Mon  2012-03-20 Tue  2012-03-21 Wed  2012-03-21 Wed  2012-03-21 Wed  2012-03-22 Thu  2012-03-23 Fri  2012-03-26 Mon
44 -7  2012-03-20 Tue  2012-03-21 Wed  2012-03-22 Thu  2012-03-22 Thu  2012-03-22 Thu  2012-03-23 Fri  2012-03-26 Mon  2012-03-27 Tue
45 -6  2012-03-21 Wed  2012-03-22 Thu  2012-03-23 Fri  2012-03-23 Fri  2012-03-23 Fri  2012-03-26 Mon  2012-03-27 Tue  2012-03-28 Wed
46 -5  2012-03-22 Thu  2012-03-23 Fri  2012-03-26 Mon  2012-03-26 Mon  2012-03-26 Mon  2012-03-27 Tue  2012-03-28 Wed  2012-03-29 Thu
47 -4  2012-03-23 Fri  2012-03-26 Mon  2012-03-27 Tue  2012-03-27 Tue  2012-03-27 Tue  2012-03-28 Wed  2012-03-29 Thu  2012-03-30 Fri
48 -3  2012-03-26 Mon  2012-03-27 Tue  2012-03-28 Wed  2012-03-28 Wed  2012-03-28 Wed  2012-03-29 Thu  2012-03-30 Fri  2012-04-02 Mon
49 -2  2012-03-27 Tue  2012-03-28 Wed  2012-03-29 Thu  2012-03-29 Thu  2012-03-29 Thu  2012-03-30 Fri  2012-04-02 Mon  2012-04-03 Tue
50 -1  2012-03-28 Wed  2012-03-29 Thu  2012-03-30 Fri  2012-03-30 Fri  2012-03-30 Fri  2012-04-02 Mon  2012-04-03 Tue  2012-04-04 Wed
51 +0  2012-03-29 Thu  2012-03-30 Fri  2012-04-02 Mon  2012-04-02 Mon  2012-04-02 Mon  2012-04-03 Tue  2012-04-04 Wed  2012-04-05 Thu
52 +1  2012-03-30 Fri  2012-04-02 Mon  2012-04-02 Mon  2012-04-02 Mon  2012-04-03 Tue  2012-04-04 Wed  2012-04-05 Thu  2012-04-06 Fri
53 +2  2012-04-02 Mon  2012-04-03 Tue  2012-04-03 Tue  2012-04-03 Tue  2012-04-04 Wed  2012-04-05 Thu  2012-04-06 Fri  2012-04-09 Mon
54 +3  2012-04-03 Tue  2012-04-04 Wed  2012-04-04 Wed  2012-04-04 Wed  2012-04-05 Thu  2012-04-06 Fri  2012-04-09 Mon  2012-04-10 Tue
55 +4  2012-04-04 Wed  2012-04-05 Thu  2012-04-05 Thu  2012-04-05 Thu  2012-04-06 Fri  2012-04-09 Mon  2012-04-10 Tue  2012-04-11 Wed
56 +5  2012-04-05 Thu  2012-04-06 Fri  2012-04-06 Fri  2012-04-06 Fri  2012-04-09 Mon  2012-04-10 Tue  2012-04-11 Wed  2012-04-12 Thu
57 +6  2012-04-06 Fri  2012-04-09 Mon  2012-04-09 Mon  2012-04-09 Mon  2012-04-10 Tue  2012-04-11 Wed  2012-04-12 Thu  2012-04-13 Fri
58 +7  2012-04-09 Mon  2012-04-10 Tue  2012-04-10 Tue  2012-04-10 Tue  2012-04-11 Wed  2012-04-12 Thu  2012-04-13 Fri  2012-04-16 Mon
59 +8  2012-04-10 Tue  2012-04-11 Wed  2012-04-11 Wed  2012-04-11 Wed  2012-04-12 Thu  2012-04-13 Fri  2012-04-16 Mon  2012-04-17 Tue
60 +9  2012-04-11 Wed  2012-04-12 Thu  2012-04-12 Thu  2012-04-12 Thu  2012-04-13 Fri  2012-04-16 Mon  2012-04-17 Tue  2012-04-18 Wed
61+10  2012-04-12 Thu  2012-04-13 Fri  2012-04-13 Fri  2012-04-13 Fri  2012-04-16 Mon  2012-04-17 Tue  2012-04-18 Wed  2012-04-19 Thu
62+11  2012-04-13 Fri  2012-04-16 Mon  2012-04-16 Mon  2012-04-16 Mon  2012-04-17 Tue  2012-04-18 Wed  2012-04-19 Thu  2012-04-20 Fri
63