@@ -48,23 +48,23 @@ describe('Calendar/DateUtils', () => {
48
48
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
49
49
expect ( dayObject . day ) . toBe ( 28 ) ;
50
50
expect ( dayObject . month ) . toBe ( 11 ) ;
51
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 6 ) ;
51
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 6 ) ;
52
52
} ) ;
53
53
54
54
it ( '2020 When Sunday is first day of the week - should return Sunday Dec 29th' , ( ) => {
55
55
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2020 , FirstDayOfWeek . SUNDAY ) ;
56
56
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
57
57
expect ( dayObject . day ) . toBe ( 29 ) ;
58
58
expect ( dayObject . month ) . toBe ( 11 ) ;
59
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 0 ) ;
59
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 0 ) ;
60
60
} ) ;
61
61
62
62
it ( '2020 When Monday is first day of the week - should return Monday Dec 30th' , ( ) => {
63
63
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2020 , FirstDayOfWeek . MONDAY ) ;
64
64
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
65
65
expect ( dayObject . day ) . toBe ( 30 ) ;
66
66
expect ( dayObject . month ) . toBe ( 11 ) ;
67
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 1 ) ;
67
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 1 ) ;
68
68
} ) ;
69
69
} ) ;
70
70
@@ -74,23 +74,23 @@ describe('Calendar/DateUtils', () => {
74
74
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
75
75
expect ( dayObject . day ) . toBe ( 26 ) ;
76
76
expect ( dayObject . month ) . toBe ( 11 ) ;
77
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 6 ) ;
77
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 6 ) ;
78
78
} ) ;
79
79
80
80
it ( '2021 When Sunday is first day of the week - should return Sunday Dec 27th' , ( ) => {
81
81
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2021 , FirstDayOfWeek . SUNDAY ) ;
82
82
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
83
83
expect ( dayObject . day ) . toBe ( 27 ) ;
84
84
expect ( dayObject . month ) . toBe ( 11 ) ;
85
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 0 ) ;
85
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 0 ) ;
86
86
} ) ;
87
87
88
88
it ( '2021 When Monday is first day of the week - should return Monday Dec 28th' , ( ) => {
89
89
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2021 , FirstDayOfWeek . MONDAY ) ;
90
90
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
91
91
expect ( dayObject . day ) . toBe ( 28 ) ;
92
92
expect ( dayObject . month ) . toBe ( 11 ) ;
93
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 1 ) ;
93
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 1 ) ;
94
94
} ) ;
95
95
} ) ;
96
96
@@ -100,23 +100,23 @@ describe('Calendar/DateUtils', () => {
100
100
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
101
101
expect ( dayObject . day ) . toBe ( 1 ) ;
102
102
expect ( dayObject . month ) . toBe ( 0 ) ;
103
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 6 ) ;
103
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 6 ) ;
104
104
} ) ;
105
105
106
106
it ( '2022 When Sunday is first day of the week - should return Sunday Dec 26th' , ( ) => {
107
107
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2022 , FirstDayOfWeek . SUNDAY ) ;
108
108
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
109
109
expect ( dayObject . day ) . toBe ( 26 ) ;
110
110
expect ( dayObject . month ) . toBe ( 11 ) ;
111
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 0 ) ;
111
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 0 ) ;
112
112
} ) ;
113
113
114
114
it ( '2022 When Monday is first day of the week - should return Monday Dec 27th' , ( ) => {
115
115
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2022 , FirstDayOfWeek . MONDAY ) ;
116
116
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
117
117
expect ( dayObject . day ) . toBe ( 27 ) ;
118
118
expect ( dayObject . month ) . toBe ( 11 ) ;
119
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 1 ) ;
119
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 1 ) ;
120
120
} ) ;
121
121
} ) ;
122
122
@@ -126,23 +126,23 @@ describe('Calendar/DateUtils', () => {
126
126
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
127
127
expect ( dayObject . day ) . toBe ( 31 ) ;
128
128
expect ( dayObject . month ) . toBe ( 11 ) ;
129
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 6 ) ;
129
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 6 ) ;
130
130
} ) ;
131
131
132
132
it ( '2023 When Sunday is first day of the week - should return Sunday Jan 1st' , ( ) => {
133
133
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2023 , FirstDayOfWeek . SUNDAY ) ;
134
134
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
135
135
expect ( dayObject . day ) . toBe ( 1 ) ;
136
136
expect ( dayObject . month ) . toBe ( 0 ) ;
137
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 0 ) ;
137
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 0 ) ;
138
138
} ) ;
139
139
140
140
it ( '2023 When Monday is first day of the week - should return Monday Dec 26th' , ( ) => {
141
141
const firstDayInTheYear = DateUtils . _forTesting . getFirstDayInTheYear ( 2023 , FirstDayOfWeek . MONDAY ) ;
142
142
const dayObject = DateUtils . getDateObject ( firstDayInTheYear ) ;
143
143
expect ( dayObject . day ) . toBe ( 26 ) ;
144
144
expect ( dayObject . month ) . toBe ( 11 ) ;
145
- expect ( DateUtils . getDayOfTheWeek ( firstDayInTheYear ) ) . toBe ( 1 ) ;
145
+ expect ( dayObject . dayOfTheWeek ) . toBe ( 1 ) ;
146
146
} ) ;
147
147
} ) ;
148
148
} ) ;
@@ -187,25 +187,6 @@ describe('Calendar/DateUtils', () => {
187
187
} ) ;
188
188
} ) ;
189
189
190
- describe ( 'getDayOfDate' , ( ) => {
191
- it ( 'should return the day number from the date timestamp' , ( ) => {
192
- const day = DateUtils . getDayOfDate ( new Date ( 2022 , 11 , 26 ) . getTime ( ) ) ;
193
- expect ( day ) . toBe ( 26 ) ;
194
- } ) ;
195
- } ) ;
196
-
197
- describe ( 'getDayOfTheWeek' , ( ) => {
198
- it ( 'should return the day of week (Sunday = 0) from the date timestamp' , ( ) => {
199
- const day = DateUtils . getDayOfTheWeek ( new Date ( 2023 , 1 , 5 ) . getTime ( ) ) ;
200
- expect ( day ) . toBe ( 0 ) ;
201
- } ) ;
202
- it ( 'should return the day of week (Friday = 5) from the date timestamp' , ( ) => {
203
- const day = DateUtils . getDayOfTheWeek ( new Date ( 2023 , 1 , 3 ) . getTime ( ) ) ;
204
- expect ( day ) . toBe ( 5 ) ;
205
- } ) ;
206
- } ) ;
207
-
208
-
209
190
describe ( 'addMonths' , ( ) => {
210
191
it ( 'should return the date timestamp for the next (1) months in the next (1) years' , ( ) => {
211
192
const date = DateUtils . addMonths ( new Date ( 2022 , 11 , 26 ) . getTime ( ) , 1 ) ;
@@ -271,6 +252,15 @@ describe('Calendar/DateUtils', () => {
271
252
expect ( dayObject . month ) . toBe ( 11 ) ;
272
253
expect ( dayObject . year ) . toBe ( 2020 ) ;
273
254
} ) ;
255
+
256
+ // useFirstDay
257
+ it ( 'should return the date timestamp for the 1st day of the next (1) months in the next (1) years' , ( ) => {
258
+ const date = DateUtils . addMonths ( new Date ( 2022 , 11 , 26 ) . getTime ( ) , 1 , true ) ;
259
+ const dayObject = DateUtils . getDateObject ( date ) ;
260
+ expect ( dayObject . day ) . toBe ( 1 ) ;
261
+ expect ( dayObject . month ) . toBe ( 0 ) ;
262
+ expect ( dayObject . year ) . toBe ( 2023 ) ;
263
+ } ) ;
274
264
} ) ;
275
265
276
266
describe ( 'addYears' , ( ) => {
0 commit comments