1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
| @isTest
| private class Consum_ApplyUtilTest {
| @isTest
| static void getWD_addday_Test() {
| // Base is FRI
| Date baseDate = Date.newInstance(2020, 1, 10);
| System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
| System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
| System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
| System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
| System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
| System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
| System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
| System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
| System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
| System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
| System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));
|
| System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -1));
| System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -2));
| System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -3));
| System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -4));
| System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -5));
| System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -6));
| System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -7));
| System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -8));
| System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -9));
| System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -10));
|
| // Base is SAT
| baseDate = Date.newInstance(2020, 1, 11);
| System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
| System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
| System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
| System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
| System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
| System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
| System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
| System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
| System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
| System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
| System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));
|
| System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
| System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
| System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
| System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
| System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
| System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
| System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
| System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
| System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
| System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
| System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));
|
| // Base is SUN
| baseDate = Date.newInstance(2020, 1, 12);
| System.assertEquals(Date.newInstance(2020, 1, 10), Consum_ApplyUtil.getWD_addday(baseDate, 0));
| System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 1));
| System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 2));
| System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 3));
| System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 4));
| System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 5));
| System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 6));
| System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 7));
| System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 8));
| System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 9));
| System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 10));
|
| System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
| System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
| System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
| System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
| System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
| System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
| System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
| System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
| System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
| System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
| System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));
|
| // Base is MON
| baseDate = Date.newInstance(2020, 1, 13);
| System.assertEquals(Date.newInstance(2020, 1, 13), Consum_ApplyUtil.getWD_addday(baseDate, 0));
| System.assertEquals(Date.newInstance(2020, 1, 14), Consum_ApplyUtil.getWD_addday(baseDate, 1));
| System.assertEquals(Date.newInstance(2020, 1, 15), Consum_ApplyUtil.getWD_addday(baseDate, 2));
| System.assertEquals(Date.newInstance(2020, 1, 16), Consum_ApplyUtil.getWD_addday(baseDate, 3));
| System.assertEquals(Date.newInstance(2020, 1, 17), Consum_ApplyUtil.getWD_addday(baseDate, 4));
| System.assertEquals(Date.newInstance(2020, 1, 20), Consum_ApplyUtil.getWD_addday(baseDate, 5));
| System.assertEquals(Date.newInstance(2020, 1, 21), Consum_ApplyUtil.getWD_addday(baseDate, 6));
| System.assertEquals(Date.newInstance(2020, 1, 22), Consum_ApplyUtil.getWD_addday(baseDate, 7));
| System.assertEquals(Date.newInstance(2020, 1, 23), Consum_ApplyUtil.getWD_addday(baseDate, 8));
| System.assertEquals(Date.newInstance(2020, 1, 24), Consum_ApplyUtil.getWD_addday(baseDate, 9));
| System.assertEquals(Date.newInstance(2020, 1, 27), Consum_ApplyUtil.getWD_addday(baseDate, 10));
|
| System.assertEquals(Date.newInstance(2020, 1,10), Consum_ApplyUtil.getWD_addday(baseDate, -1));
| System.assertEquals(Date.newInstance(2020, 1, 9), Consum_ApplyUtil.getWD_addday(baseDate, -2));
| System.assertEquals(Date.newInstance(2020, 1, 8), Consum_ApplyUtil.getWD_addday(baseDate, -3));
| System.assertEquals(Date.newInstance(2020, 1, 7), Consum_ApplyUtil.getWD_addday(baseDate, -4));
| System.assertEquals(Date.newInstance(2020, 1, 6), Consum_ApplyUtil.getWD_addday(baseDate, -5));
| System.assertEquals(Date.newInstance(2020, 1, 3), Consum_ApplyUtil.getWD_addday(baseDate, -6));
| System.assertEquals(Date.newInstance(2020, 1, 2), Consum_ApplyUtil.getWD_addday(baseDate, -7));
| System.assertEquals(Date.newInstance(2020, 1, 1), Consum_ApplyUtil.getWD_addday(baseDate, -8));
| System.assertEquals(Date.newInstance(2019,12,31), Consum_ApplyUtil.getWD_addday(baseDate, -9));
| System.assertEquals(Date.newInstance(2019,12,30), Consum_ApplyUtil.getWD_addday(baseDate, -10));
| System.assertEquals(Date.newInstance(2019,12,27), Consum_ApplyUtil.getWD_addday(baseDate, -11));
| }
| }
|
|