@uxf/datepicker 11.94.0 → 11.96.0-canary.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/use-date-picker-navigation.js +12 -12
- package/hooks/use-date-picker.js +5 -5
- package/hooks/use-date-picker.test.js +1 -1
- package/hooks/use-date-range-picker.js +17 -17
- package/hooks/use-date-range-picker.test.js +2 -2
- package/hooks/use-day.js +11 -11
- package/hooks/use-day.test.js +5 -5
- package/hooks/use-decade.js +5 -5
- package/hooks/use-decade.test.js +21 -21
- package/hooks/use-month.js +4 -4
- package/hooks/use-month.test.js +81 -81
- package/hooks/use-year.js +3 -3
- package/hooks/use-year.test.js +27 -27
- package/package.json +1 -1
- package/utils/can-select-range.js +7 -7
- package/utils/dayjs-utils.d.ts +4 -0
- package/utils/{dayjs-en.js → dayjs-utils.js} +8 -5
- package/utils/get-current-year-month-and-date.js +2 -2
- package/utils/get-current-year-month-and-date.test.js +2 -2
- package/utils/get-date-intervals.test.js +12 -8
- package/utils/get-date-invervals.js +3 -3
- package/utils/get-date-month-and-year.js +4 -4
- package/utils/get-date-month-and-year.test.js +2 -2
- package/utils/get-days.js +9 -9
- package/utils/get-days.test.js +121 -121
- package/utils/get-each.js +7 -90
- package/utils/get-each.test.js +15 -15
- package/utils/get-initial-months.js +2 -2
- package/utils/get-initial-months.test.js +4 -4
- package/utils/get-months.js +4 -4
- package/utils/get-months.test.js +26 -26
- package/utils/get-next-active-month.js +3 -3
- package/utils/get-next-active-month.test.js +14 -14
- package/utils/get-weekday-labels.js +4 -4
- package/utils/get-weekday-labels.test.js +3 -3
- package/utils/get-years.js +2 -2
- package/utils/get-years.test.js +10 -10
- package/utils/is-date-blocked.js +4 -4
- package/utils/is-date-hovered.js +8 -8
- package/utils/is-date-inside-range.js +2 -2
- package/utils/is-end-date.js +2 -2
- package/utils/is-first-or-last-selected-date.js +3 -2
- package/utils/is-in-unavailable-dates.js +2 -2
- package/utils/is-start-date.js +2 -2
- package/utils/dayjs-en.d.ts +0 -3
package/utils/get-days.test.js
CHANGED
|
@@ -1,135 +1,135 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
4
4
|
const get_days_1 = require("./get-days");
|
|
5
5
|
test("getDays", () => {
|
|
6
6
|
expect((0, get_days_1.getDays)({ year: 2021, month: 0 })).toStrictEqual([
|
|
7
|
-
{ dayLabel: "27", date: new Date("2020-12-27T00:00:
|
|
8
|
-
{ dayLabel: "28", date: new Date("2020-12-28T00:00:
|
|
9
|
-
{ dayLabel: "29", date: new Date("2020-12-29T00:00:
|
|
10
|
-
{ dayLabel: "30", date: new Date("2020-12-30T00:00:
|
|
11
|
-
{ dayLabel: "31", date: new Date("2020-12-31T00:00:
|
|
12
|
-
{ dayLabel: "01", date: new Date("2021-01-01T00:00:
|
|
13
|
-
{ dayLabel: "02", date: new Date("2021-01-02T00:00:
|
|
14
|
-
{ dayLabel: "03", date: new Date("2021-01-03T00:00:
|
|
15
|
-
{ dayLabel: "04", date: new Date("2021-01-04T00:00:
|
|
16
|
-
{ dayLabel: "05", date: new Date("2021-01-05T00:00:
|
|
17
|
-
{ dayLabel: "06", date: new Date("2021-01-06T00:00:
|
|
18
|
-
{ dayLabel: "07", date: new Date("2021-01-07T00:00:
|
|
19
|
-
{ dayLabel: "08", date: new Date("2021-01-08T00:00:
|
|
20
|
-
{ dayLabel: "09", date: new Date("2021-01-09T00:00:
|
|
21
|
-
{ dayLabel: "10", date: new Date("2021-01-10T00:00:
|
|
22
|
-
{ dayLabel: "11", date: new Date("2021-01-11T00:00:
|
|
23
|
-
{ dayLabel: "12", date: new Date("2021-01-12T00:00:
|
|
24
|
-
{ dayLabel: "13", date: new Date("2021-01-13T00:00:
|
|
25
|
-
{ dayLabel: "14", date: new Date("2021-01-14T00:00:
|
|
26
|
-
{ dayLabel: "15", date: new Date("2021-01-15T00:00:
|
|
27
|
-
{ dayLabel: "16", date: new Date("2021-01-16T00:00:
|
|
28
|
-
{ dayLabel: "17", date: new Date("2021-01-17T00:00:
|
|
29
|
-
{ dayLabel: "18", date: new Date("2021-01-18T00:00:
|
|
30
|
-
{ dayLabel: "19", date: new Date("2021-01-19T00:00:
|
|
31
|
-
{ dayLabel: "20", date: new Date("2021-01-20T00:00:
|
|
32
|
-
{ dayLabel: "21", date: new Date("2021-01-21T00:00:
|
|
33
|
-
{ dayLabel: "22", date: new Date("2021-01-22T00:00:
|
|
34
|
-
{ dayLabel: "23", date: new Date("2021-01-23T00:00:
|
|
35
|
-
{ dayLabel: "24", date: new Date("2021-01-24T00:00:
|
|
36
|
-
{ dayLabel: "25", date: new Date("2021-01-25T00:00:
|
|
37
|
-
{ dayLabel: "26", date: new Date("2021-01-26T00:00:
|
|
38
|
-
{ dayLabel: "27", date: new Date("2021-01-27T00:00:
|
|
39
|
-
{ dayLabel: "28", date: new Date("2021-01-28T00:00:
|
|
40
|
-
{ dayLabel: "29", date: new Date("2021-01-29T00:00:
|
|
41
|
-
{ dayLabel: "30", date: new Date("2021-01-30T00:00:
|
|
42
|
-
{ dayLabel: "31", date: new Date("2021-01-31T00:00:
|
|
43
|
-
{ dayLabel: "01", date: new Date("2021-02-01T00:00:
|
|
44
|
-
{ dayLabel: "02", date: new Date("2021-02-02T00:00:
|
|
45
|
-
{ dayLabel: "03", date: new Date("2021-02-03T00:00:
|
|
46
|
-
{ dayLabel: "04", date: new Date("2021-02-04T00:00:
|
|
47
|
-
{ dayLabel: "05", date: new Date("2021-02-05T00:00:
|
|
48
|
-
{ dayLabel: "06", date: new Date("2021-02-06T00:00:
|
|
7
|
+
{ dayLabel: "27", date: new Date("2020-12-27T00:00:00Z"), currentMonth: false },
|
|
8
|
+
{ dayLabel: "28", date: new Date("2020-12-28T00:00:00Z"), currentMonth: false },
|
|
9
|
+
{ dayLabel: "29", date: new Date("2020-12-29T00:00:00Z"), currentMonth: false },
|
|
10
|
+
{ dayLabel: "30", date: new Date("2020-12-30T00:00:00Z"), currentMonth: false },
|
|
11
|
+
{ dayLabel: "31", date: new Date("2020-12-31T00:00:00Z"), currentMonth: false },
|
|
12
|
+
{ dayLabel: "01", date: new Date("2021-01-01T00:00:00Z"), currentMonth: true },
|
|
13
|
+
{ dayLabel: "02", date: new Date("2021-01-02T00:00:00Z"), currentMonth: true },
|
|
14
|
+
{ dayLabel: "03", date: new Date("2021-01-03T00:00:00Z"), currentMonth: true },
|
|
15
|
+
{ dayLabel: "04", date: new Date("2021-01-04T00:00:00Z"), currentMonth: true },
|
|
16
|
+
{ dayLabel: "05", date: new Date("2021-01-05T00:00:00Z"), currentMonth: true },
|
|
17
|
+
{ dayLabel: "06", date: new Date("2021-01-06T00:00:00Z"), currentMonth: true },
|
|
18
|
+
{ dayLabel: "07", date: new Date("2021-01-07T00:00:00Z"), currentMonth: true },
|
|
19
|
+
{ dayLabel: "08", date: new Date("2021-01-08T00:00:00Z"), currentMonth: true },
|
|
20
|
+
{ dayLabel: "09", date: new Date("2021-01-09T00:00:00Z"), currentMonth: true },
|
|
21
|
+
{ dayLabel: "10", date: new Date("2021-01-10T00:00:00Z"), currentMonth: true },
|
|
22
|
+
{ dayLabel: "11", date: new Date("2021-01-11T00:00:00Z"), currentMonth: true },
|
|
23
|
+
{ dayLabel: "12", date: new Date("2021-01-12T00:00:00Z"), currentMonth: true },
|
|
24
|
+
{ dayLabel: "13", date: new Date("2021-01-13T00:00:00Z"), currentMonth: true },
|
|
25
|
+
{ dayLabel: "14", date: new Date("2021-01-14T00:00:00Z"), currentMonth: true },
|
|
26
|
+
{ dayLabel: "15", date: new Date("2021-01-15T00:00:00Z"), currentMonth: true },
|
|
27
|
+
{ dayLabel: "16", date: new Date("2021-01-16T00:00:00Z"), currentMonth: true },
|
|
28
|
+
{ dayLabel: "17", date: new Date("2021-01-17T00:00:00Z"), currentMonth: true },
|
|
29
|
+
{ dayLabel: "18", date: new Date("2021-01-18T00:00:00Z"), currentMonth: true },
|
|
30
|
+
{ dayLabel: "19", date: new Date("2021-01-19T00:00:00Z"), currentMonth: true },
|
|
31
|
+
{ dayLabel: "20", date: new Date("2021-01-20T00:00:00Z"), currentMonth: true },
|
|
32
|
+
{ dayLabel: "21", date: new Date("2021-01-21T00:00:00Z"), currentMonth: true },
|
|
33
|
+
{ dayLabel: "22", date: new Date("2021-01-22T00:00:00Z"), currentMonth: true },
|
|
34
|
+
{ dayLabel: "23", date: new Date("2021-01-23T00:00:00Z"), currentMonth: true },
|
|
35
|
+
{ dayLabel: "24", date: new Date("2021-01-24T00:00:00Z"), currentMonth: true },
|
|
36
|
+
{ dayLabel: "25", date: new Date("2021-01-25T00:00:00Z"), currentMonth: true },
|
|
37
|
+
{ dayLabel: "26", date: new Date("2021-01-26T00:00:00Z"), currentMonth: true },
|
|
38
|
+
{ dayLabel: "27", date: new Date("2021-01-27T00:00:00Z"), currentMonth: true },
|
|
39
|
+
{ dayLabel: "28", date: new Date("2021-01-28T00:00:00Z"), currentMonth: true },
|
|
40
|
+
{ dayLabel: "29", date: new Date("2021-01-29T00:00:00Z"), currentMonth: true },
|
|
41
|
+
{ dayLabel: "30", date: new Date("2021-01-30T00:00:00Z"), currentMonth: true },
|
|
42
|
+
{ dayLabel: "31", date: new Date("2021-01-31T00:00:00Z"), currentMonth: true },
|
|
43
|
+
{ dayLabel: "01", date: new Date("2021-02-01T00:00:00Z"), currentMonth: false },
|
|
44
|
+
{ dayLabel: "02", date: new Date("2021-02-02T00:00:00Z"), currentMonth: false },
|
|
45
|
+
{ dayLabel: "03", date: new Date("2021-02-03T00:00:00Z"), currentMonth: false },
|
|
46
|
+
{ dayLabel: "04", date: new Date("2021-02-04T00:00:00Z"), currentMonth: false },
|
|
47
|
+
{ dayLabel: "05", date: new Date("2021-02-05T00:00:00Z"), currentMonth: false },
|
|
48
|
+
{ dayLabel: "06", date: new Date("2021-02-06T00:00:00Z"), currentMonth: false },
|
|
49
49
|
]);
|
|
50
50
|
});
|
|
51
51
|
test("getDays with custom format", () => {
|
|
52
|
-
expect((0, get_days_1.getDays)({ year: 2021, month: 0, dayLabelFormat: (date) => (0,
|
|
53
|
-
{ dayLabel: "27", date: new Date("2020-12-27T00:00:
|
|
54
|
-
{ dayLabel: "28", date: new Date("2020-12-28T00:00:
|
|
55
|
-
{ dayLabel: "29", date: new Date("2020-12-29T00:00:
|
|
56
|
-
{ dayLabel: "30", date: new Date("2020-12-30T00:00:
|
|
57
|
-
{ dayLabel: "31", date: new Date("2020-12-31T00:00:
|
|
58
|
-
{ dayLabel: "1", date: new Date("2021-01-01T00:00:
|
|
59
|
-
{ dayLabel: "2", date: new Date("2021-01-02T00:00:
|
|
60
|
-
{ dayLabel: "3", date: new Date("2021-01-03T00:00:
|
|
61
|
-
{ dayLabel: "4", date: new Date("2021-01-04T00:00:
|
|
62
|
-
{ dayLabel: "5", date: new Date("2021-01-05T00:00:
|
|
63
|
-
{ dayLabel: "6", date: new Date("2021-01-06T00:00:
|
|
64
|
-
{ dayLabel: "7", date: new Date("2021-01-07T00:00:
|
|
65
|
-
{ dayLabel: "8", date: new Date("2021-01-08T00:00:
|
|
66
|
-
{ dayLabel: "9", date: new Date("2021-01-09T00:00:
|
|
67
|
-
{ dayLabel: "10", date: new Date("2021-01-10T00:00:
|
|
68
|
-
{ dayLabel: "11", date: new Date("2021-01-11T00:00:
|
|
69
|
-
{ dayLabel: "12", date: new Date("2021-01-12T00:00:
|
|
70
|
-
{ dayLabel: "13", date: new Date("2021-01-13T00:00:
|
|
71
|
-
{ dayLabel: "14", date: new Date("2021-01-14T00:00:
|
|
72
|
-
{ dayLabel: "15", date: new Date("2021-01-15T00:00:
|
|
73
|
-
{ dayLabel: "16", date: new Date("2021-01-16T00:00:
|
|
74
|
-
{ dayLabel: "17", date: new Date("2021-01-17T00:00:
|
|
75
|
-
{ dayLabel: "18", date: new Date("2021-01-18T00:00:
|
|
76
|
-
{ dayLabel: "19", date: new Date("2021-01-19T00:00:
|
|
77
|
-
{ dayLabel: "20", date: new Date("2021-01-20T00:00:
|
|
78
|
-
{ dayLabel: "21", date: new Date("2021-01-21T00:00:
|
|
79
|
-
{ dayLabel: "22", date: new Date("2021-01-22T00:00:
|
|
80
|
-
{ dayLabel: "23", date: new Date("2021-01-23T00:00:
|
|
81
|
-
{ dayLabel: "24", date: new Date("2021-01-24T00:00:
|
|
82
|
-
{ dayLabel: "25", date: new Date("2021-01-25T00:00:
|
|
83
|
-
{ dayLabel: "26", date: new Date("2021-01-26T00:00:
|
|
84
|
-
{ dayLabel: "27", date: new Date("2021-01-27T00:00:
|
|
85
|
-
{ dayLabel: "28", date: new Date("2021-01-28T00:00:
|
|
86
|
-
{ dayLabel: "29", date: new Date("2021-01-29T00:00:
|
|
87
|
-
{ dayLabel: "30", date: new Date("2021-01-30T00:00:
|
|
88
|
-
{ dayLabel: "31", date: new Date("2021-01-31T00:00:
|
|
89
|
-
{ dayLabel: "1", date: new Date("2021-02-01T00:00:
|
|
90
|
-
{ dayLabel: "2", date: new Date("2021-02-02T00:00:
|
|
91
|
-
{ dayLabel: "3", date: new Date("2021-02-03T00:00:
|
|
92
|
-
{ dayLabel: "4", date: new Date("2021-02-04T00:00:
|
|
93
|
-
{ dayLabel: "5", date: new Date("2021-02-05T00:00:
|
|
94
|
-
{ dayLabel: "6", date: new Date("2021-02-06T00:00:
|
|
52
|
+
expect((0, get_days_1.getDays)({ year: 2021, month: 0, dayLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("D") })).toStrictEqual([
|
|
53
|
+
{ dayLabel: "27", date: new Date("2020-12-27T00:00:00Z"), currentMonth: false },
|
|
54
|
+
{ dayLabel: "28", date: new Date("2020-12-28T00:00:00Z"), currentMonth: false },
|
|
55
|
+
{ dayLabel: "29", date: new Date("2020-12-29T00:00:00Z"), currentMonth: false },
|
|
56
|
+
{ dayLabel: "30", date: new Date("2020-12-30T00:00:00Z"), currentMonth: false },
|
|
57
|
+
{ dayLabel: "31", date: new Date("2020-12-31T00:00:00Z"), currentMonth: false },
|
|
58
|
+
{ dayLabel: "1", date: new Date("2021-01-01T00:00:00Z"), currentMonth: true },
|
|
59
|
+
{ dayLabel: "2", date: new Date("2021-01-02T00:00:00Z"), currentMonth: true },
|
|
60
|
+
{ dayLabel: "3", date: new Date("2021-01-03T00:00:00Z"), currentMonth: true },
|
|
61
|
+
{ dayLabel: "4", date: new Date("2021-01-04T00:00:00Z"), currentMonth: true },
|
|
62
|
+
{ dayLabel: "5", date: new Date("2021-01-05T00:00:00Z"), currentMonth: true },
|
|
63
|
+
{ dayLabel: "6", date: new Date("2021-01-06T00:00:00Z"), currentMonth: true },
|
|
64
|
+
{ dayLabel: "7", date: new Date("2021-01-07T00:00:00Z"), currentMonth: true },
|
|
65
|
+
{ dayLabel: "8", date: new Date("2021-01-08T00:00:00Z"), currentMonth: true },
|
|
66
|
+
{ dayLabel: "9", date: new Date("2021-01-09T00:00:00Z"), currentMonth: true },
|
|
67
|
+
{ dayLabel: "10", date: new Date("2021-01-10T00:00:00Z"), currentMonth: true },
|
|
68
|
+
{ dayLabel: "11", date: new Date("2021-01-11T00:00:00Z"), currentMonth: true },
|
|
69
|
+
{ dayLabel: "12", date: new Date("2021-01-12T00:00:00Z"), currentMonth: true },
|
|
70
|
+
{ dayLabel: "13", date: new Date("2021-01-13T00:00:00Z"), currentMonth: true },
|
|
71
|
+
{ dayLabel: "14", date: new Date("2021-01-14T00:00:00Z"), currentMonth: true },
|
|
72
|
+
{ dayLabel: "15", date: new Date("2021-01-15T00:00:00Z"), currentMonth: true },
|
|
73
|
+
{ dayLabel: "16", date: new Date("2021-01-16T00:00:00Z"), currentMonth: true },
|
|
74
|
+
{ dayLabel: "17", date: new Date("2021-01-17T00:00:00Z"), currentMonth: true },
|
|
75
|
+
{ dayLabel: "18", date: new Date("2021-01-18T00:00:00Z"), currentMonth: true },
|
|
76
|
+
{ dayLabel: "19", date: new Date("2021-01-19T00:00:00Z"), currentMonth: true },
|
|
77
|
+
{ dayLabel: "20", date: new Date("2021-01-20T00:00:00Z"), currentMonth: true },
|
|
78
|
+
{ dayLabel: "21", date: new Date("2021-01-21T00:00:00Z"), currentMonth: true },
|
|
79
|
+
{ dayLabel: "22", date: new Date("2021-01-22T00:00:00Z"), currentMonth: true },
|
|
80
|
+
{ dayLabel: "23", date: new Date("2021-01-23T00:00:00Z"), currentMonth: true },
|
|
81
|
+
{ dayLabel: "24", date: new Date("2021-01-24T00:00:00Z"), currentMonth: true },
|
|
82
|
+
{ dayLabel: "25", date: new Date("2021-01-25T00:00:00Z"), currentMonth: true },
|
|
83
|
+
{ dayLabel: "26", date: new Date("2021-01-26T00:00:00Z"), currentMonth: true },
|
|
84
|
+
{ dayLabel: "27", date: new Date("2021-01-27T00:00:00Z"), currentMonth: true },
|
|
85
|
+
{ dayLabel: "28", date: new Date("2021-01-28T00:00:00Z"), currentMonth: true },
|
|
86
|
+
{ dayLabel: "29", date: new Date("2021-01-29T00:00:00Z"), currentMonth: true },
|
|
87
|
+
{ dayLabel: "30", date: new Date("2021-01-30T00:00:00Z"), currentMonth: true },
|
|
88
|
+
{ dayLabel: "31", date: new Date("2021-01-31T00:00:00Z"), currentMonth: true },
|
|
89
|
+
{ dayLabel: "1", date: new Date("2021-02-01T00:00:00Z"), currentMonth: false },
|
|
90
|
+
{ dayLabel: "2", date: new Date("2021-02-02T00:00:00Z"), currentMonth: false },
|
|
91
|
+
{ dayLabel: "3", date: new Date("2021-02-03T00:00:00Z"), currentMonth: false },
|
|
92
|
+
{ dayLabel: "4", date: new Date("2021-02-04T00:00:00Z"), currentMonth: false },
|
|
93
|
+
{ dayLabel: "5", date: new Date("2021-02-05T00:00:00Z"), currentMonth: false },
|
|
94
|
+
{ dayLabel: "6", date: new Date("2021-02-06T00:00:00Z"), currentMonth: false },
|
|
95
95
|
]);
|
|
96
96
|
});
|
|
97
97
|
test("getDays with custom firstDayOfWeek", () => {
|
|
98
98
|
expect((0, get_days_1.getDays)({ year: 2021, month: 0, firstDayOfWeek: 1 })).toStrictEqual([
|
|
99
|
-
{ dayLabel: "28", date: new Date("2020-12-28T00:00:
|
|
100
|
-
{ dayLabel: "29", date: new Date("2020-12-29T00:00:
|
|
101
|
-
{ dayLabel: "30", date: new Date("2020-12-30T00:00:
|
|
102
|
-
{ dayLabel: "31", date: new Date("2020-12-31T00:00:
|
|
103
|
-
{ dayLabel: "01", date: new Date("2021-01-01T00:00:
|
|
104
|
-
{ dayLabel: "02", date: new Date("2021-01-02T00:00:
|
|
105
|
-
{ dayLabel: "03", date: new Date("2021-01-03T00:00:
|
|
106
|
-
{ dayLabel: "04", date: new Date("2021-01-04T00:00:
|
|
107
|
-
{ dayLabel: "05", date: new Date("2021-01-05T00:00:
|
|
108
|
-
{ dayLabel: "06", date: new Date("2021-01-06T00:00:
|
|
109
|
-
{ dayLabel: "07", date: new Date("2021-01-07T00:00:
|
|
110
|
-
{ dayLabel: "08", date: new Date("2021-01-08T00:00:
|
|
111
|
-
{ dayLabel: "09", date: new Date("2021-01-09T00:00:
|
|
112
|
-
{ dayLabel: "10", date: new Date("2021-01-10T00:00:
|
|
113
|
-
{ dayLabel: "11", date: new Date("2021-01-11T00:00:
|
|
114
|
-
{ dayLabel: "12", date: new Date("2021-01-12T00:00:
|
|
115
|
-
{ dayLabel: "13", date: new Date("2021-01-13T00:00:
|
|
116
|
-
{ dayLabel: "14", date: new Date("2021-01-14T00:00:
|
|
117
|
-
{ dayLabel: "15", date: new Date("2021-01-15T00:00:
|
|
118
|
-
{ dayLabel: "16", date: new Date("2021-01-16T00:00:
|
|
119
|
-
{ dayLabel: "17", date: new Date("2021-01-17T00:00:
|
|
120
|
-
{ dayLabel: "18", date: new Date("2021-01-18T00:00:
|
|
121
|
-
{ dayLabel: "19", date: new Date("2021-01-19T00:00:
|
|
122
|
-
{ dayLabel: "20", date: new Date("2021-01-20T00:00:
|
|
123
|
-
{ dayLabel: "21", date: new Date("2021-01-21T00:00:
|
|
124
|
-
{ dayLabel: "22", date: new Date("2021-01-22T00:00:
|
|
125
|
-
{ dayLabel: "23", date: new Date("2021-01-23T00:00:
|
|
126
|
-
{ dayLabel: "24", date: new Date("2021-01-24T00:00:
|
|
127
|
-
{ dayLabel: "25", date: new Date("2021-01-25T00:00:
|
|
128
|
-
{ dayLabel: "26", date: new Date("2021-01-26T00:00:
|
|
129
|
-
{ dayLabel: "27", date: new Date("2021-01-27T00:00:
|
|
130
|
-
{ dayLabel: "28", date: new Date("2021-01-28T00:00:
|
|
131
|
-
{ dayLabel: "29", date: new Date("2021-01-29T00:00:
|
|
132
|
-
{ dayLabel: "30", date: new Date("2021-01-30T00:00:
|
|
133
|
-
{ dayLabel: "31", date: new Date("2021-01-31T00:00:
|
|
99
|
+
{ dayLabel: "28", date: new Date("2020-12-28T00:00:00Z"), currentMonth: false },
|
|
100
|
+
{ dayLabel: "29", date: new Date("2020-12-29T00:00:00Z"), currentMonth: false },
|
|
101
|
+
{ dayLabel: "30", date: new Date("2020-12-30T00:00:00Z"), currentMonth: false },
|
|
102
|
+
{ dayLabel: "31", date: new Date("2020-12-31T00:00:00Z"), currentMonth: false },
|
|
103
|
+
{ dayLabel: "01", date: new Date("2021-01-01T00:00:00Z"), currentMonth: true },
|
|
104
|
+
{ dayLabel: "02", date: new Date("2021-01-02T00:00:00Z"), currentMonth: true },
|
|
105
|
+
{ dayLabel: "03", date: new Date("2021-01-03T00:00:00Z"), currentMonth: true },
|
|
106
|
+
{ dayLabel: "04", date: new Date("2021-01-04T00:00:00Z"), currentMonth: true },
|
|
107
|
+
{ dayLabel: "05", date: new Date("2021-01-05T00:00:00Z"), currentMonth: true },
|
|
108
|
+
{ dayLabel: "06", date: new Date("2021-01-06T00:00:00Z"), currentMonth: true },
|
|
109
|
+
{ dayLabel: "07", date: new Date("2021-01-07T00:00:00Z"), currentMonth: true },
|
|
110
|
+
{ dayLabel: "08", date: new Date("2021-01-08T00:00:00Z"), currentMonth: true },
|
|
111
|
+
{ dayLabel: "09", date: new Date("2021-01-09T00:00:00Z"), currentMonth: true },
|
|
112
|
+
{ dayLabel: "10", date: new Date("2021-01-10T00:00:00Z"), currentMonth: true },
|
|
113
|
+
{ dayLabel: "11", date: new Date("2021-01-11T00:00:00Z"), currentMonth: true },
|
|
114
|
+
{ dayLabel: "12", date: new Date("2021-01-12T00:00:00Z"), currentMonth: true },
|
|
115
|
+
{ dayLabel: "13", date: new Date("2021-01-13T00:00:00Z"), currentMonth: true },
|
|
116
|
+
{ dayLabel: "14", date: new Date("2021-01-14T00:00:00Z"), currentMonth: true },
|
|
117
|
+
{ dayLabel: "15", date: new Date("2021-01-15T00:00:00Z"), currentMonth: true },
|
|
118
|
+
{ dayLabel: "16", date: new Date("2021-01-16T00:00:00Z"), currentMonth: true },
|
|
119
|
+
{ dayLabel: "17", date: new Date("2021-01-17T00:00:00Z"), currentMonth: true },
|
|
120
|
+
{ dayLabel: "18", date: new Date("2021-01-18T00:00:00Z"), currentMonth: true },
|
|
121
|
+
{ dayLabel: "19", date: new Date("2021-01-19T00:00:00Z"), currentMonth: true },
|
|
122
|
+
{ dayLabel: "20", date: new Date("2021-01-20T00:00:00Z"), currentMonth: true },
|
|
123
|
+
{ dayLabel: "21", date: new Date("2021-01-21T00:00:00Z"), currentMonth: true },
|
|
124
|
+
{ dayLabel: "22", date: new Date("2021-01-22T00:00:00Z"), currentMonth: true },
|
|
125
|
+
{ dayLabel: "23", date: new Date("2021-01-23T00:00:00Z"), currentMonth: true },
|
|
126
|
+
{ dayLabel: "24", date: new Date("2021-01-24T00:00:00Z"), currentMonth: true },
|
|
127
|
+
{ dayLabel: "25", date: new Date("2021-01-25T00:00:00Z"), currentMonth: true },
|
|
128
|
+
{ dayLabel: "26", date: new Date("2021-01-26T00:00:00Z"), currentMonth: true },
|
|
129
|
+
{ dayLabel: "27", date: new Date("2021-01-27T00:00:00Z"), currentMonth: true },
|
|
130
|
+
{ dayLabel: "28", date: new Date("2021-01-28T00:00:00Z"), currentMonth: true },
|
|
131
|
+
{ dayLabel: "29", date: new Date("2021-01-29T00:00:00Z"), currentMonth: true },
|
|
132
|
+
{ dayLabel: "30", date: new Date("2021-01-30T00:00:00Z"), currentMonth: true },
|
|
133
|
+
{ dayLabel: "31", date: new Date("2021-01-31T00:00:00Z"), currentMonth: true },
|
|
134
134
|
]);
|
|
135
135
|
});
|
package/utils/get-each.js
CHANGED
|
@@ -1,101 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEach = getEach;
|
|
4
|
-
const
|
|
5
|
-
const DAY_IN_MS = 24 * 60 * 60 * 1000;
|
|
6
|
-
const partsFormatter = new Intl.DateTimeFormat("en-GB", {
|
|
7
|
-
timeZone: DEFAULT_TIMEZONE,
|
|
8
|
-
year: "numeric",
|
|
9
|
-
month: "numeric",
|
|
10
|
-
day: "numeric",
|
|
11
|
-
hour: "numeric",
|
|
12
|
-
hour12: false,
|
|
13
|
-
});
|
|
14
|
-
const hourFormatter = new Intl.DateTimeFormat("en-GB", {
|
|
15
|
-
timeZone: DEFAULT_TIMEZONE,
|
|
16
|
-
hour: "numeric",
|
|
17
|
-
hour12: false,
|
|
18
|
-
});
|
|
19
|
-
function getHour(date) {
|
|
20
|
-
return parseInt(hourFormatter.format(date), 10) % 24;
|
|
21
|
-
}
|
|
22
|
-
function getDateParts(date) {
|
|
23
|
-
const parts = partsFormatter.formatToParts(date);
|
|
24
|
-
let year = 0;
|
|
25
|
-
let month = 0;
|
|
26
|
-
let day = 0;
|
|
27
|
-
let hour = 0;
|
|
28
|
-
for (let i = 0; i < parts.length; i++) {
|
|
29
|
-
const part = parts[i];
|
|
30
|
-
if (part.type === "year") {
|
|
31
|
-
year = parseInt(part.value, 10);
|
|
32
|
-
}
|
|
33
|
-
else if (part.type === "month") {
|
|
34
|
-
month = parseInt(part.value, 10);
|
|
35
|
-
}
|
|
36
|
-
else if (part.type === "day") {
|
|
37
|
-
day = parseInt(part.value, 10);
|
|
38
|
-
}
|
|
39
|
-
else if (part.type === "hour") {
|
|
40
|
-
hour = parseInt(part.value, 10);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return { year, month, day, hour: hour % 24 };
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates a date in the default timezone (Prague)
|
|
47
|
-
*/
|
|
48
|
-
function createDate(year, month, day) {
|
|
49
|
-
const date = new Date(Date.UTC(year, month - 1, day));
|
|
50
|
-
const hour = getHour(date);
|
|
51
|
-
if (hour !== 0) {
|
|
52
|
-
// Adjust UTC midnight to Prague midnight
|
|
53
|
-
// Prague is UTC+1 or UTC+2, so hour will be 1 or 2 (or 23/24 if something shifted)
|
|
54
|
-
const diff = hour > 12 ? hour - 24 : hour;
|
|
55
|
-
date.setUTCHours(date.getUTCHours() - diff);
|
|
56
|
-
}
|
|
57
|
-
return date;
|
|
58
|
-
}
|
|
59
|
-
function startOf(date, type) {
|
|
60
|
-
const p = getDateParts(date);
|
|
61
|
-
if (type === "year") {
|
|
62
|
-
return createDate(p.year, 1, 1);
|
|
63
|
-
}
|
|
64
|
-
if (type === "month") {
|
|
65
|
-
return createDate(p.year, p.month, 1);
|
|
66
|
-
}
|
|
67
|
-
return createDate(p.year, p.month, p.day);
|
|
68
|
-
}
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
69
5
|
function getEach(start, end, type) {
|
|
70
|
-
const startOfStart =
|
|
71
|
-
const startOfEnd =
|
|
72
|
-
if (startOfStart.getTime() > startOfEnd.getTime()) {
|
|
6
|
+
const startOfStart = (0, dayjs_utils_1.dayjsEnWithTz)(start).startOf(type);
|
|
7
|
+
const startOfEnd = (0, dayjs_utils_1.dayjsEnWithTz)(end).startOf(type);
|
|
8
|
+
if (startOfStart.toDate().getTime() > startOfEnd.toDate().getTime()) {
|
|
73
9
|
throw new Error("start must precede end");
|
|
74
10
|
}
|
|
75
11
|
const results = [];
|
|
76
12
|
let current = startOfStart;
|
|
77
|
-
while (current.getTime() <= startOfEnd.getTime()) {
|
|
78
|
-
results.push(
|
|
79
|
-
|
|
80
|
-
// Optimized day increment: add 24 hours and correct for DST if needed
|
|
81
|
-
const next = new Date(current.getTime() + DAY_IN_MS);
|
|
82
|
-
const hour = getHour(next);
|
|
83
|
-
if (hour !== 0) {
|
|
84
|
-
const diff = hour > 12 ? hour - 24 : hour;
|
|
85
|
-
next.setUTCHours(next.getUTCHours() - diff);
|
|
86
|
-
}
|
|
87
|
-
current = next;
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
const p = getDateParts(current);
|
|
91
|
-
if (type === "year") {
|
|
92
|
-
current = createDate(p.year + 1, 1, 1);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
// month
|
|
96
|
-
current = createDate(p.year, p.month + 1, 1);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
13
|
+
while (current.toDate().getTime() <= startOfEnd.toDate().getTime()) {
|
|
14
|
+
results.push(current.toDate());
|
|
15
|
+
current = current.add(1, type);
|
|
99
16
|
}
|
|
100
17
|
return results;
|
|
101
18
|
}
|
package/utils/get-each.test.js
CHANGED
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const get_each_1 = require("./get-each");
|
|
4
4
|
test("getEach day", () => {
|
|
5
|
-
expect((0, get_each_1.getEach)(new Date("2021-05-
|
|
6
|
-
new Date("2021-05-05T00:00:
|
|
7
|
-
new Date("2021-05-06T00:00:
|
|
8
|
-
new Date("2021-05-07T00:00:
|
|
5
|
+
expect((0, get_each_1.getEach)(new Date("2021-05-05"), new Date("2021-05-07"), "day")).toStrictEqual([
|
|
6
|
+
new Date("2021-05-05T00:00:00Z"),
|
|
7
|
+
new Date("2021-05-06T00:00:00Z"),
|
|
8
|
+
new Date("2021-05-07T00:00:00Z"),
|
|
9
9
|
]);
|
|
10
10
|
});
|
|
11
11
|
test("getEach month", () => {
|
|
12
12
|
expect((0, get_each_1.getEach)(new Date("2021-05-05"), new Date("2021-08-07"), "month")).toStrictEqual([
|
|
13
|
-
new Date("2021-05-01T00:00:
|
|
14
|
-
new Date("2021-06-01T00:00:
|
|
15
|
-
new Date("2021-07-01T00:00:
|
|
16
|
-
new Date("2021-08-01T00:00:
|
|
13
|
+
new Date("2021-05-01T00:00:00Z"),
|
|
14
|
+
new Date("2021-06-01T00:00:00Z"),
|
|
15
|
+
new Date("2021-07-01T00:00:00Z"),
|
|
16
|
+
new Date("2021-08-01T00:00:00Z"),
|
|
17
17
|
]);
|
|
18
18
|
});
|
|
19
19
|
test("getEach year", () => {
|
|
20
20
|
expect((0, get_each_1.getEach)(new Date("2015-05-05"), new Date("2020-05-07"), "year")).toStrictEqual([
|
|
21
|
-
new Date("2015-01-01T00:00:
|
|
22
|
-
new Date("2016-01-01T00:00:
|
|
23
|
-
new Date("2017-01-01T00:00:
|
|
24
|
-
new Date("2018-01-01T00:00:
|
|
25
|
-
new Date("2019-01-01T00:00:
|
|
26
|
-
new Date("2020-01-01T00:00:
|
|
21
|
+
new Date("2015-01-01T00:00:00Z"),
|
|
22
|
+
new Date("2016-01-01T00:00:00Z"),
|
|
23
|
+
new Date("2017-01-01T00:00:00Z"),
|
|
24
|
+
new Date("2018-01-01T00:00:00Z"),
|
|
25
|
+
new Date("2019-01-01T00:00:00Z"),
|
|
26
|
+
new Date("2020-01-01T00:00:00Z"),
|
|
27
27
|
]);
|
|
28
28
|
});
|
|
29
29
|
test("getEach invalid input", () => {
|
|
30
|
-
expect(() => (0, get_each_1.getEach)(new Date("2015-05-05"), new Date("2014-05-07T00:00:
|
|
30
|
+
expect(() => (0, get_each_1.getEach)(new Date("2015-05-05"), new Date("2014-05-07T00:00:00Z"), "day")).toThrow();
|
|
31
31
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInitialMonths = getInitialMonths;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
|
|
6
6
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
7
7
|
function getInitialMonths(numberOfMonths, startDate) {
|
|
@@ -10,7 +10,7 @@ function getInitialMonths(numberOfMonths, startDate) {
|
|
|
10
10
|
let months = [firstMonth];
|
|
11
11
|
if (numberOfMonths > 1) {
|
|
12
12
|
months = Array.from(Array(numberOfMonths - 1).keys()).reduce((m) => {
|
|
13
|
-
prevMonthDate = (0,
|
|
13
|
+
prevMonthDate = (0, dayjs_utils_1.dayjsEnRaw)(m[m.length - 1].date)
|
|
14
14
|
.add(1, "month")
|
|
15
15
|
.toDate();
|
|
16
16
|
return m.concat([(0, get_date_month_and_year_1.getDateMonthAndYear)(prevMonthDate)]);
|
|
@@ -4,7 +4,7 @@ const get_initial_months_1 = require("./get-initial-months");
|
|
|
4
4
|
test("getInitialMonths", () => {
|
|
5
5
|
expect((0, get_initial_months_1.getInitialMonths)(1, new Date("2021-09-15"))).toStrictEqual([
|
|
6
6
|
{
|
|
7
|
-
date: new Date("2021-09-01T00:00:
|
|
7
|
+
date: new Date("2021-09-01T00:00:00Z"),
|
|
8
8
|
month: 8,
|
|
9
9
|
year: 2021,
|
|
10
10
|
},
|
|
@@ -13,12 +13,12 @@ test("getInitialMonths", () => {
|
|
|
13
13
|
test("getInitialMonths 2 months", () => {
|
|
14
14
|
expect((0, get_initial_months_1.getInitialMonths)(2, new Date("2021-09-15"))).toStrictEqual([
|
|
15
15
|
{
|
|
16
|
-
date: new Date("2021-09-01T00:00:
|
|
16
|
+
date: new Date("2021-09-01T00:00:00Z"),
|
|
17
17
|
month: 8,
|
|
18
18
|
year: 2021,
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
date: new Date("2021-10-01T00:00:
|
|
21
|
+
date: new Date("2021-10-01T00:00:00Z"),
|
|
22
22
|
month: 9,
|
|
23
23
|
year: 2021,
|
|
24
24
|
},
|
|
@@ -29,7 +29,7 @@ test("getInitialMonths without date", () => {
|
|
|
29
29
|
jest.setSystemTime(new Date("2021-09-15"));
|
|
30
30
|
expect((0, get_initial_months_1.getInitialMonths)(1, null)).toStrictEqual([
|
|
31
31
|
{
|
|
32
|
-
date: new Date("2021-09-01T00:00:
|
|
32
|
+
date: new Date("2021-09-01T00:00:00Z"),
|
|
33
33
|
month: 8,
|
|
34
34
|
year: 2021,
|
|
35
35
|
},
|
package/utils/get-months.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMonths = getMonths;
|
|
4
4
|
const create_date_string_1 = require("./create-date-string");
|
|
5
|
-
const
|
|
5
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
6
6
|
const get_each_1 = require("./get-each");
|
|
7
|
-
function getMonths({ year, monthLabelFormat = (date) => (0,
|
|
7
|
+
function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MMMM"), }) {
|
|
8
8
|
const date = new Date((0, create_date_string_1.createDateString)(year, 0));
|
|
9
|
-
const yearStart = (0,
|
|
10
|
-
const yearEnd = (0,
|
|
9
|
+
const yearStart = (0, dayjs_utils_1.dayjsEnWithTz)(date).startOf("year").toDate();
|
|
10
|
+
const yearEnd = (0, dayjs_utils_1.dayjsEnWithTz)(date).endOf("year").toDate();
|
|
11
11
|
return (0, get_each_1.getEach)(yearStart, yearEnd, "month").map((d) => ({
|
|
12
12
|
date: d,
|
|
13
13
|
monthLabel: monthLabelFormat(d),
|
package/utils/get-months.test.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
4
4
|
const get_months_1 = require("./get-months");
|
|
5
5
|
test("getMonths", () => {
|
|
6
6
|
expect((0, get_months_1.getMonths)({ year: 2021 })).toStrictEqual([
|
|
7
|
-
{ monthLabel: "January", date: new Date("2021-01-01T00:00:
|
|
8
|
-
{ monthLabel: "February", date: new Date("2021-02-01T00:00:
|
|
9
|
-
{ monthLabel: "March", date: new Date("2021-03-01T00:00:
|
|
10
|
-
{ monthLabel: "April", date: new Date("2021-04-01T00:00:
|
|
11
|
-
{ monthLabel: "May", date: new Date("2021-05-01T00:00:
|
|
12
|
-
{ monthLabel: "June", date: new Date("2021-06-01T00:00:
|
|
13
|
-
{ monthLabel: "July", date: new Date("2021-07-01T00:00:
|
|
14
|
-
{ monthLabel: "August", date: new Date("2021-08-01T00:00:
|
|
15
|
-
{ monthLabel: "September", date: new Date("2021-09-01T00:00:
|
|
16
|
-
{ monthLabel: "October", date: new Date("2021-10-01T00:00:
|
|
17
|
-
{ monthLabel: "November", date: new Date("2021-11-01T00:00:
|
|
18
|
-
{ monthLabel: "December", date: new Date("2021-12-01T00:00:
|
|
7
|
+
{ monthLabel: "January", date: new Date("2021-01-01T00:00:00Z") },
|
|
8
|
+
{ monthLabel: "February", date: new Date("2021-02-01T00:00:00Z") },
|
|
9
|
+
{ monthLabel: "March", date: new Date("2021-03-01T00:00:00Z") },
|
|
10
|
+
{ monthLabel: "April", date: new Date("2021-04-01T00:00:00Z") },
|
|
11
|
+
{ monthLabel: "May", date: new Date("2021-05-01T00:00:00Z") },
|
|
12
|
+
{ monthLabel: "June", date: new Date("2021-06-01T00:00:00Z") },
|
|
13
|
+
{ monthLabel: "July", date: new Date("2021-07-01T00:00:00Z") },
|
|
14
|
+
{ monthLabel: "August", date: new Date("2021-08-01T00:00:00Z") },
|
|
15
|
+
{ monthLabel: "September", date: new Date("2021-09-01T00:00:00Z") },
|
|
16
|
+
{ monthLabel: "October", date: new Date("2021-10-01T00:00:00Z") },
|
|
17
|
+
{ monthLabel: "November", date: new Date("2021-11-01T00:00:00Z") },
|
|
18
|
+
{ monthLabel: "December", date: new Date("2021-12-01T00:00:00Z") },
|
|
19
19
|
]);
|
|
20
20
|
});
|
|
21
21
|
test("getMonths with custom format", () => {
|
|
22
|
-
expect((0, get_months_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0,
|
|
23
|
-
{ monthLabel: "01", date: new Date("2021-01-01T00:00:
|
|
24
|
-
{ monthLabel: "02", date: new Date("2021-02-01T00:00:
|
|
25
|
-
{ monthLabel: "03", date: new Date("2021-03-01T00:00:
|
|
26
|
-
{ monthLabel: "04", date: new Date("2021-04-01T00:00:
|
|
27
|
-
{ monthLabel: "05", date: new Date("2021-05-01T00:00:
|
|
28
|
-
{ monthLabel: "06", date: new Date("2021-06-01T00:00:
|
|
29
|
-
{ monthLabel: "07", date: new Date("2021-07-01T00:00:
|
|
30
|
-
{ monthLabel: "08", date: new Date("2021-08-01T00:00:
|
|
31
|
-
{ monthLabel: "09", date: new Date("2021-09-01T00:00:
|
|
32
|
-
{ monthLabel: "10", date: new Date("2021-10-01T00:00:
|
|
33
|
-
{ monthLabel: "11", date: new Date("2021-11-01T00:00:
|
|
34
|
-
{ monthLabel: "12", date: new Date("2021-12-01T00:00:
|
|
22
|
+
expect((0, get_months_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0, dayjs_utils_1.dayjsEnWithTz)(date).format("MM") })).toStrictEqual([
|
|
23
|
+
{ monthLabel: "01", date: new Date("2021-01-01T00:00:00Z") },
|
|
24
|
+
{ monthLabel: "02", date: new Date("2021-02-01T00:00:00Z") },
|
|
25
|
+
{ monthLabel: "03", date: new Date("2021-03-01T00:00:00Z") },
|
|
26
|
+
{ monthLabel: "04", date: new Date("2021-04-01T00:00:00Z") },
|
|
27
|
+
{ monthLabel: "05", date: new Date("2021-05-01T00:00:00Z") },
|
|
28
|
+
{ monthLabel: "06", date: new Date("2021-06-01T00:00:00Z") },
|
|
29
|
+
{ monthLabel: "07", date: new Date("2021-07-01T00:00:00Z") },
|
|
30
|
+
{ monthLabel: "08", date: new Date("2021-08-01T00:00:00Z") },
|
|
31
|
+
{ monthLabel: "09", date: new Date("2021-09-01T00:00:00Z") },
|
|
32
|
+
{ monthLabel: "10", date: new Date("2021-10-01T00:00:00Z") },
|
|
33
|
+
{ monthLabel: "11", date: new Date("2021-11-01T00:00:00Z") },
|
|
34
|
+
{ monthLabel: "12", date: new Date("2021-12-01T00:00:00Z") },
|
|
35
35
|
]);
|
|
36
36
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNextActiveMonth = getNextActiveMonth;
|
|
4
|
-
const
|
|
4
|
+
const dayjs_utils_1 = require("./dayjs-utils");
|
|
5
5
|
const get_date_month_and_year_1 = require("./get-date-month-and-year");
|
|
6
6
|
function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
|
|
7
7
|
let prevMonth;
|
|
@@ -14,10 +14,10 @@ function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
|
|
|
14
14
|
let prevMonthDate = activeMonth[prevMonth].date;
|
|
15
15
|
return Array.from(Array(numberOfMonths).keys()).reduce((m) => {
|
|
16
16
|
if (m.length === 0) {
|
|
17
|
-
prevMonthDate = (0,
|
|
17
|
+
prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate).add(counter, "month").startOf("month").toDate();
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
prevMonthDate = (0,
|
|
20
|
+
prevMonthDate = (0, dayjs_utils_1.dayjsEnWithTz)(prevMonthDate)
|
|
21
21
|
.add(counter >= 0 ? 1 : -1, "month")
|
|
22
22
|
.startOf("month")
|
|
23
23
|
.toDate();
|