@uxf/datepicker 11.94.0 → 11.96.0-canary.1

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.
@@ -3,133 +3,136 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const dayjs_en_1 = require("./dayjs-en");
4
4
  const get_days_1 = require("./get-days");
5
5
  test("getDays", () => {
6
- expect((0, get_days_1.getDays)({ year: 2021, month: 0 })).toStrictEqual([
7
- { dayLabel: "27", date: new Date("2020-12-27T00:00:00+01:00"), currentMonth: false },
8
- { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00"), currentMonth: false },
9
- { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00"), currentMonth: false },
10
- { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00"), currentMonth: false },
11
- { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00"), currentMonth: false },
12
- { dayLabel: "01", date: new Date("2021-01-01T00:00:00+01:00"), currentMonth: true },
13
- { dayLabel: "02", date: new Date("2021-01-02T00:00:00+01:00"), currentMonth: true },
14
- { dayLabel: "03", date: new Date("2021-01-03T00:00:00+01:00"), currentMonth: true },
15
- { dayLabel: "04", date: new Date("2021-01-04T00:00:00+01:00"), currentMonth: true },
16
- { dayLabel: "05", date: new Date("2021-01-05T00:00:00+01:00"), currentMonth: true },
17
- { dayLabel: "06", date: new Date("2021-01-06T00:00:00+01:00"), currentMonth: true },
18
- { dayLabel: "07", date: new Date("2021-01-07T00:00:00+01:00"), currentMonth: true },
19
- { dayLabel: "08", date: new Date("2021-01-08T00:00:00+01:00"), currentMonth: true },
20
- { dayLabel: "09", date: new Date("2021-01-09T00:00:00+01:00"), currentMonth: true },
21
- { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00"), currentMonth: true },
22
- { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00"), currentMonth: true },
23
- { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00"), currentMonth: true },
24
- { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00"), currentMonth: true },
25
- { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00"), currentMonth: true },
26
- { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00"), currentMonth: true },
27
- { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00"), currentMonth: true },
28
- { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00"), currentMonth: true },
29
- { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00"), currentMonth: true },
30
- { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00"), currentMonth: true },
31
- { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00"), currentMonth: true },
32
- { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00"), currentMonth: true },
33
- { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00"), currentMonth: true },
34
- { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00"), currentMonth: true },
35
- { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00"), currentMonth: true },
36
- { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00"), currentMonth: true },
37
- { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00"), currentMonth: true },
38
- { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00"), currentMonth: true },
39
- { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00"), currentMonth: true },
40
- { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00"), currentMonth: true },
41
- { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00"), currentMonth: true },
42
- { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00"), currentMonth: true },
43
- { dayLabel: "01", date: new Date("2021-02-01T00:00:00+01:00"), currentMonth: false },
44
- { dayLabel: "02", date: new Date("2021-02-02T00:00:00+01:00"), currentMonth: false },
45
- { dayLabel: "03", date: new Date("2021-02-03T00:00:00+01:00"), currentMonth: false },
46
- { dayLabel: "04", date: new Date("2021-02-04T00:00:00+01:00"), currentMonth: false },
47
- { dayLabel: "05", date: new Date("2021-02-05T00:00:00+01:00"), currentMonth: false },
48
- { dayLabel: "06", date: new Date("2021-02-06T00:00:00+01:00"), currentMonth: false },
6
+ expect((0, get_days_1.getDays)({ year: 2021, month: 0 }).map((d) => ({ ...d, date: d.date.toUTCString() }))).toStrictEqual([
7
+ { dayLabel: "27", date: new Date("2020-12-27T00:00:00+01:00").toUTCString(), currentMonth: false },
8
+ { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00").toUTCString(), currentMonth: false },
9
+ { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00").toUTCString(), currentMonth: false },
10
+ { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00").toUTCString(), currentMonth: false },
11
+ { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00").toUTCString(), currentMonth: false },
12
+ { dayLabel: "01", date: new Date("2021-01-01T00:00:00+01:00").toUTCString(), currentMonth: true },
13
+ { dayLabel: "02", date: new Date("2021-01-02T00:00:00+01:00").toUTCString(), currentMonth: true },
14
+ { dayLabel: "03", date: new Date("2021-01-03T00:00:00+01:00").toUTCString(), currentMonth: true },
15
+ { dayLabel: "04", date: new Date("2021-01-04T00:00:00+01:00").toUTCString(), currentMonth: true },
16
+ { dayLabel: "05", date: new Date("2021-01-05T00:00:00+01:00").toUTCString(), currentMonth: true },
17
+ { dayLabel: "06", date: new Date("2021-01-06T00:00:00+01:00").toUTCString(), currentMonth: true },
18
+ { dayLabel: "07", date: new Date("2021-01-07T00:00:00+01:00").toUTCString(), currentMonth: true },
19
+ { dayLabel: "08", date: new Date("2021-01-08T00:00:00+01:00").toUTCString(), currentMonth: true },
20
+ { dayLabel: "09", date: new Date("2021-01-09T00:00:00+01:00").toUTCString(), currentMonth: true },
21
+ { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00").toUTCString(), currentMonth: true },
22
+ { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00").toUTCString(), currentMonth: true },
23
+ { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00").toUTCString(), currentMonth: true },
24
+ { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00").toUTCString(), currentMonth: true },
25
+ { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00").toUTCString(), currentMonth: true },
26
+ { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00").toUTCString(), currentMonth: true },
27
+ { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00").toUTCString(), currentMonth: true },
28
+ { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00").toUTCString(), currentMonth: true },
29
+ { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00").toUTCString(), currentMonth: true },
30
+ { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00").toUTCString(), currentMonth: true },
31
+ { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00").toUTCString(), currentMonth: true },
32
+ { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00").toUTCString(), currentMonth: true },
33
+ { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00").toUTCString(), currentMonth: true },
34
+ { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00").toUTCString(), currentMonth: true },
35
+ { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00").toUTCString(), currentMonth: true },
36
+ { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00").toUTCString(), currentMonth: true },
37
+ { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00").toUTCString(), currentMonth: true },
38
+ { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00").toUTCString(), currentMonth: true },
39
+ { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00").toUTCString(), currentMonth: true },
40
+ { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00").toUTCString(), currentMonth: true },
41
+ { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00").toUTCString(), currentMonth: true },
42
+ { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00").toUTCString(), currentMonth: true },
43
+ { dayLabel: "01", date: new Date("2021-02-01T00:00:00+01:00").toUTCString(), currentMonth: false },
44
+ { dayLabel: "02", date: new Date("2021-02-02T00:00:00+01:00").toUTCString(), currentMonth: false },
45
+ { dayLabel: "03", date: new Date("2021-02-03T00:00:00+01:00").toUTCString(), currentMonth: false },
46
+ { dayLabel: "04", date: new Date("2021-02-04T00:00:00+01:00").toUTCString(), currentMonth: false },
47
+ { dayLabel: "05", date: new Date("2021-02-05T00:00:00+01:00").toUTCString(), currentMonth: false },
48
+ { dayLabel: "06", date: new Date("2021-02-06T00:00:00+01:00").toUTCString(), 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, dayjs_en_1.dayjsEn)(date).format("D") })).toStrictEqual([
53
- { dayLabel: "27", date: new Date("2020-12-27T00:00:00+01:00"), currentMonth: false },
54
- { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00"), currentMonth: false },
55
- { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00"), currentMonth: false },
56
- { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00"), currentMonth: false },
57
- { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00"), currentMonth: false },
58
- { dayLabel: "1", date: new Date("2021-01-01T00:00:00+01:00"), currentMonth: true },
59
- { dayLabel: "2", date: new Date("2021-01-02T00:00:00+01:00"), currentMonth: true },
60
- { dayLabel: "3", date: new Date("2021-01-03T00:00:00+01:00"), currentMonth: true },
61
- { dayLabel: "4", date: new Date("2021-01-04T00:00:00+01:00"), currentMonth: true },
62
- { dayLabel: "5", date: new Date("2021-01-05T00:00:00+01:00"), currentMonth: true },
63
- { dayLabel: "6", date: new Date("2021-01-06T00:00:00+01:00"), currentMonth: true },
64
- { dayLabel: "7", date: new Date("2021-01-07T00:00:00+01:00"), currentMonth: true },
65
- { dayLabel: "8", date: new Date("2021-01-08T00:00:00+01:00"), currentMonth: true },
66
- { dayLabel: "9", date: new Date("2021-01-09T00:00:00+01:00"), currentMonth: true },
67
- { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00"), currentMonth: true },
68
- { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00"), currentMonth: true },
69
- { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00"), currentMonth: true },
70
- { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00"), currentMonth: true },
71
- { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00"), currentMonth: true },
72
- { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00"), currentMonth: true },
73
- { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00"), currentMonth: true },
74
- { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00"), currentMonth: true },
75
- { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00"), currentMonth: true },
76
- { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00"), currentMonth: true },
77
- { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00"), currentMonth: true },
78
- { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00"), currentMonth: true },
79
- { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00"), currentMonth: true },
80
- { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00"), currentMonth: true },
81
- { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00"), currentMonth: true },
82
- { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00"), currentMonth: true },
83
- { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00"), currentMonth: true },
84
- { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00"), currentMonth: true },
85
- { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00"), currentMonth: true },
86
- { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00"), currentMonth: true },
87
- { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00"), currentMonth: true },
88
- { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00"), currentMonth: true },
89
- { dayLabel: "1", date: new Date("2021-02-01T00:00:00+01:00"), currentMonth: false },
90
- { dayLabel: "2", date: new Date("2021-02-02T00:00:00+01:00"), currentMonth: false },
91
- { dayLabel: "3", date: new Date("2021-02-03T00:00:00+01:00"), currentMonth: false },
92
- { dayLabel: "4", date: new Date("2021-02-04T00:00:00+01:00"), currentMonth: false },
93
- { dayLabel: "5", date: new Date("2021-02-05T00:00:00+01:00"), currentMonth: false },
94
- { dayLabel: "6", date: new Date("2021-02-06T00:00:00+01:00"), currentMonth: false },
52
+ expect((0, get_days_1.getDays)({ year: 2021, month: 0, dayLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("D") }).map((d) => ({
53
+ ...d,
54
+ date: d.date.toUTCString(),
55
+ }))).toStrictEqual([
56
+ { dayLabel: "27", date: new Date("2020-12-27T00:00:00+01:00").toUTCString(), currentMonth: false },
57
+ { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00").toUTCString(), currentMonth: false },
58
+ { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00").toUTCString(), currentMonth: false },
59
+ { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00").toUTCString(), currentMonth: false },
60
+ { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00").toUTCString(), currentMonth: false },
61
+ { dayLabel: "1", date: new Date("2021-01-01T00:00:00+01:00").toUTCString(), currentMonth: true },
62
+ { dayLabel: "2", date: new Date("2021-01-02T00:00:00+01:00").toUTCString(), currentMonth: true },
63
+ { dayLabel: "3", date: new Date("2021-01-03T00:00:00+01:00").toUTCString(), currentMonth: true },
64
+ { dayLabel: "4", date: new Date("2021-01-04T00:00:00+01:00").toUTCString(), currentMonth: true },
65
+ { dayLabel: "5", date: new Date("2021-01-05T00:00:00+01:00").toUTCString(), currentMonth: true },
66
+ { dayLabel: "6", date: new Date("2021-01-06T00:00:00+01:00").toUTCString(), currentMonth: true },
67
+ { dayLabel: "7", date: new Date("2021-01-07T00:00:00+01:00").toUTCString(), currentMonth: true },
68
+ { dayLabel: "8", date: new Date("2021-01-08T00:00:00+01:00").toUTCString(), currentMonth: true },
69
+ { dayLabel: "9", date: new Date("2021-01-09T00:00:00+01:00").toUTCString(), currentMonth: true },
70
+ { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00").toUTCString(), currentMonth: true },
71
+ { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00").toUTCString(), currentMonth: true },
72
+ { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00").toUTCString(), currentMonth: true },
73
+ { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00").toUTCString(), currentMonth: true },
74
+ { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00").toUTCString(), currentMonth: true },
75
+ { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00").toUTCString(), currentMonth: true },
76
+ { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00").toUTCString(), currentMonth: true },
77
+ { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00").toUTCString(), currentMonth: true },
78
+ { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00").toUTCString(), currentMonth: true },
79
+ { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00").toUTCString(), currentMonth: true },
80
+ { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00").toUTCString(), currentMonth: true },
81
+ { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00").toUTCString(), currentMonth: true },
82
+ { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00").toUTCString(), currentMonth: true },
83
+ { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00").toUTCString(), currentMonth: true },
84
+ { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00").toUTCString(), currentMonth: true },
85
+ { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00").toUTCString(), currentMonth: true },
86
+ { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00").toUTCString(), currentMonth: true },
87
+ { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00").toUTCString(), currentMonth: true },
88
+ { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00").toUTCString(), currentMonth: true },
89
+ { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00").toUTCString(), currentMonth: true },
90
+ { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00").toUTCString(), currentMonth: true },
91
+ { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00").toUTCString(), currentMonth: true },
92
+ { dayLabel: "1", date: new Date("2021-02-01T00:00:00+01:00").toUTCString(), currentMonth: false },
93
+ { dayLabel: "2", date: new Date("2021-02-02T00:00:00+01:00").toUTCString(), currentMonth: false },
94
+ { dayLabel: "3", date: new Date("2021-02-03T00:00:00+01:00").toUTCString(), currentMonth: false },
95
+ { dayLabel: "4", date: new Date("2021-02-04T00:00:00+01:00").toUTCString(), currentMonth: false },
96
+ { dayLabel: "5", date: new Date("2021-02-05T00:00:00+01:00").toUTCString(), currentMonth: false },
97
+ { dayLabel: "6", date: new Date("2021-02-06T00:00:00+01:00").toUTCString(), currentMonth: false },
95
98
  ]);
96
99
  });
97
100
  test("getDays with custom firstDayOfWeek", () => {
98
- expect((0, get_days_1.getDays)({ year: 2021, month: 0, firstDayOfWeek: 1 })).toStrictEqual([
99
- { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00"), currentMonth: false },
100
- { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00"), currentMonth: false },
101
- { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00"), currentMonth: false },
102
- { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00"), currentMonth: false },
103
- { dayLabel: "01", date: new Date("2021-01-01T00:00:00+01:00"), currentMonth: true },
104
- { dayLabel: "02", date: new Date("2021-01-02T00:00:00+01:00"), currentMonth: true },
105
- { dayLabel: "03", date: new Date("2021-01-03T00:00:00+01:00"), currentMonth: true },
106
- { dayLabel: "04", date: new Date("2021-01-04T00:00:00+01:00"), currentMonth: true },
107
- { dayLabel: "05", date: new Date("2021-01-05T00:00:00+01:00"), currentMonth: true },
108
- { dayLabel: "06", date: new Date("2021-01-06T00:00:00+01:00"), currentMonth: true },
109
- { dayLabel: "07", date: new Date("2021-01-07T00:00:00+01:00"), currentMonth: true },
110
- { dayLabel: "08", date: new Date("2021-01-08T00:00:00+01:00"), currentMonth: true },
111
- { dayLabel: "09", date: new Date("2021-01-09T00:00:00+01:00"), currentMonth: true },
112
- { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00"), currentMonth: true },
113
- { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00"), currentMonth: true },
114
- { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00"), currentMonth: true },
115
- { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00"), currentMonth: true },
116
- { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00"), currentMonth: true },
117
- { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00"), currentMonth: true },
118
- { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00"), currentMonth: true },
119
- { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00"), currentMonth: true },
120
- { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00"), currentMonth: true },
121
- { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00"), currentMonth: true },
122
- { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00"), currentMonth: true },
123
- { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00"), currentMonth: true },
124
- { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00"), currentMonth: true },
125
- { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00"), currentMonth: true },
126
- { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00"), currentMonth: true },
127
- { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00"), currentMonth: true },
128
- { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00"), currentMonth: true },
129
- { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00"), currentMonth: true },
130
- { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00"), currentMonth: true },
131
- { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00"), currentMonth: true },
132
- { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00"), currentMonth: true },
133
- { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00"), currentMonth: true },
101
+ expect((0, get_days_1.getDays)({ year: 2021, month: 0, firstDayOfWeek: 1 }).map((d) => ({ ...d, date: d.date.toUTCString() }))).toStrictEqual([
102
+ { dayLabel: "28", date: new Date("2020-12-28T00:00:00+01:00").toUTCString(), currentMonth: false },
103
+ { dayLabel: "29", date: new Date("2020-12-29T00:00:00+01:00").toUTCString(), currentMonth: false },
104
+ { dayLabel: "30", date: new Date("2020-12-30T00:00:00+01:00").toUTCString(), currentMonth: false },
105
+ { dayLabel: "31", date: new Date("2020-12-31T00:00:00+01:00").toUTCString(), currentMonth: false },
106
+ { dayLabel: "01", date: new Date("2021-01-01T00:00:00+01:00").toUTCString(), currentMonth: true },
107
+ { dayLabel: "02", date: new Date("2021-01-02T00:00:00+01:00").toUTCString(), currentMonth: true },
108
+ { dayLabel: "03", date: new Date("2021-01-03T00:00:00+01:00").toUTCString(), currentMonth: true },
109
+ { dayLabel: "04", date: new Date("2021-01-04T00:00:00+01:00").toUTCString(), currentMonth: true },
110
+ { dayLabel: "05", date: new Date("2021-01-05T00:00:00+01:00").toUTCString(), currentMonth: true },
111
+ { dayLabel: "06", date: new Date("2021-01-06T00:00:00+01:00").toUTCString(), currentMonth: true },
112
+ { dayLabel: "07", date: new Date("2021-01-07T00:00:00+01:00").toUTCString(), currentMonth: true },
113
+ { dayLabel: "08", date: new Date("2021-01-08T00:00:00+01:00").toUTCString(), currentMonth: true },
114
+ { dayLabel: "09", date: new Date("2021-01-09T00:00:00+01:00").toUTCString(), currentMonth: true },
115
+ { dayLabel: "10", date: new Date("2021-01-10T00:00:00+01:00").toUTCString(), currentMonth: true },
116
+ { dayLabel: "11", date: new Date("2021-01-11T00:00:00+01:00").toUTCString(), currentMonth: true },
117
+ { dayLabel: "12", date: new Date("2021-01-12T00:00:00+01:00").toUTCString(), currentMonth: true },
118
+ { dayLabel: "13", date: new Date("2021-01-13T00:00:00+01:00").toUTCString(), currentMonth: true },
119
+ { dayLabel: "14", date: new Date("2021-01-14T00:00:00+01:00").toUTCString(), currentMonth: true },
120
+ { dayLabel: "15", date: new Date("2021-01-15T00:00:00+01:00").toUTCString(), currentMonth: true },
121
+ { dayLabel: "16", date: new Date("2021-01-16T00:00:00+01:00").toUTCString(), currentMonth: true },
122
+ { dayLabel: "17", date: new Date("2021-01-17T00:00:00+01:00").toUTCString(), currentMonth: true },
123
+ { dayLabel: "18", date: new Date("2021-01-18T00:00:00+01:00").toUTCString(), currentMonth: true },
124
+ { dayLabel: "19", date: new Date("2021-01-19T00:00:00+01:00").toUTCString(), currentMonth: true },
125
+ { dayLabel: "20", date: new Date("2021-01-20T00:00:00+01:00").toUTCString(), currentMonth: true },
126
+ { dayLabel: "21", date: new Date("2021-01-21T00:00:00+01:00").toUTCString(), currentMonth: true },
127
+ { dayLabel: "22", date: new Date("2021-01-22T00:00:00+01:00").toUTCString(), currentMonth: true },
128
+ { dayLabel: "23", date: new Date("2021-01-23T00:00:00+01:00").toUTCString(), currentMonth: true },
129
+ { dayLabel: "24", date: new Date("2021-01-24T00:00:00+01:00").toUTCString(), currentMonth: true },
130
+ { dayLabel: "25", date: new Date("2021-01-25T00:00:00+01:00").toUTCString(), currentMonth: true },
131
+ { dayLabel: "26", date: new Date("2021-01-26T00:00:00+01:00").toUTCString(), currentMonth: true },
132
+ { dayLabel: "27", date: new Date("2021-01-27T00:00:00+01:00").toUTCString(), currentMonth: true },
133
+ { dayLabel: "28", date: new Date("2021-01-28T00:00:00+01:00").toUTCString(), currentMonth: true },
134
+ { dayLabel: "29", date: new Date("2021-01-29T00:00:00+01:00").toUTCString(), currentMonth: true },
135
+ { dayLabel: "30", date: new Date("2021-01-30T00:00:00+01:00").toUTCString(), currentMonth: true },
136
+ { dayLabel: "31", date: new Date("2021-01-31T00:00:00+01:00").toUTCString(), currentMonth: true },
134
137
  ]);
135
138
  });
package/utils/get-each.js CHANGED
@@ -1,101 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEach = getEach;
4
- const DEFAULT_TIMEZONE = "Europe/Prague";
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);
4
+ const tz_1 = require("@date-fns/tz");
5
+ const date_fns_1 = require("date-fns");
6
+ const dayjs_en_1 = require("./dayjs-en");
7
+ function getStartOf(date, type) {
8
+ switch (type) {
9
+ case "day":
10
+ return (0, date_fns_1.startOfDay)(date);
11
+ case "month":
12
+ return (0, date_fns_1.startOfMonth)(date);
13
+ case "year":
14
+ return (0, date_fns_1.startOfYear)(date);
56
15
  }
57
- return date;
58
16
  }
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);
17
+ function getNext(date, type) {
18
+ switch (type) {
19
+ case "day":
20
+ return (0, date_fns_1.addDays)(date, 1);
21
+ case "month":
22
+ return (0, date_fns_1.addMonths)(date, 1);
23
+ case "year":
24
+ return (0, date_fns_1.addYears)(date, 1);
66
25
  }
67
- return createDate(p.year, p.month, p.day);
68
26
  }
69
27
  function getEach(start, end, type) {
70
- const startOfStart = startOf(start, type);
71
- const startOfEnd = startOf(end, type);
72
- if (startOfStart.getTime() > startOfEnd.getTime()) {
28
+ const startOfStart = getStartOf(new tz_1.TZDate(start, dayjs_en_1.DEFAULT_TIMEZONE), type);
29
+ const startOfEnd = getStartOf(new tz_1.TZDate(end, dayjs_en_1.DEFAULT_TIMEZONE), type);
30
+ if (startOfStart > startOfEnd) {
73
31
  throw new Error("start must precede end");
74
32
  }
75
33
  const results = [];
76
34
  let current = startOfStart;
77
- while (current.getTime() <= startOfEnd.getTime()) {
78
- results.push(new Date(current.getTime()));
79
- if (type === "day") {
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
- }
35
+ while (current <= startOfEnd) {
36
+ results.push(current);
37
+ current = getNext(current, type);
99
38
  }
100
39
  return results;
101
40
  }
@@ -2,28 +2,28 @@
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-05T00:00:00+02:00"), new Date("2021-05-07T00:00:00+02:00"), "day")).toStrictEqual([
6
- new Date("2021-05-05T00:00:00+02:00"),
7
- new Date("2021-05-06T00:00:00+02:00"),
8
- new Date("2021-05-07T00:00:00+02:00"),
5
+ expect((0, get_each_1.getEach)(new Date("2021-05-05T00:00:00+02:00"), new Date("2021-05-07T00:00:00+02:00"), "day").map((d) => d.toUTCString())).toStrictEqual([
6
+ new Date("2021-05-05T00:00:00+02:00").toUTCString(),
7
+ new Date("2021-05-06T00:00:00+02:00").toUTCString(),
8
+ new Date("2021-05-07T00:00:00+02:00").toUTCString(),
9
9
  ]);
10
10
  });
11
11
  test("getEach month", () => {
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:00+02:00"),
14
- new Date("2021-06-01T00:00:00+02:00"),
15
- new Date("2021-07-01T00:00:00+02:00"),
16
- new Date("2021-08-01T00:00:00+02:00"),
12
+ expect((0, get_each_1.getEach)(new Date("2021-05-05"), new Date("2021-08-07"), "month").map((d) => d.toUTCString())).toStrictEqual([
13
+ new Date("2021-05-01T00:00:00+02:00").toUTCString(),
14
+ new Date("2021-06-01T00:00:00+02:00").toUTCString(),
15
+ new Date("2021-07-01T00:00:00+02:00").toUTCString(),
16
+ new Date("2021-08-01T00:00:00+02:00").toUTCString(),
17
17
  ]);
18
18
  });
19
19
  test("getEach year", () => {
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:00+01:00"),
22
- new Date("2016-01-01T00:00:00+01:00"),
23
- new Date("2017-01-01T00:00:00+01:00"),
24
- new Date("2018-01-01T00:00:00+01:00"),
25
- new Date("2019-01-01T00:00:00+01:00"),
26
- new Date("2020-01-01T00:00:00+01:00"),
20
+ expect((0, get_each_1.getEach)(new Date("2015-05-05"), new Date("2020-05-07"), "year").map((d) => d.toUTCString())).toStrictEqual([
21
+ new Date("2015-01-01T00:00:00+01:00").toUTCString(),
22
+ new Date("2016-01-01T00:00:00+01:00").toUTCString(),
23
+ new Date("2017-01-01T00:00:00+01:00").toUTCString(),
24
+ new Date("2018-01-01T00:00:00+01:00").toUTCString(),
25
+ new Date("2019-01-01T00:00:00+01:00").toUTCString(),
26
+ new Date("2020-01-01T00:00:00+01:00").toUTCString(),
27
27
  ]);
28
28
  });
29
29
  test("getEach invalid input", () => {
@@ -3,34 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const dayjs_en_1 = require("./dayjs-en");
4
4
  const get_months_1 = require("./get-months");
5
5
  test("getMonths", () => {
6
- expect((0, get_months_1.getMonths)({ year: 2021 })).toStrictEqual([
7
- { monthLabel: "January", date: new Date("2021-01-01T00:00:00+01:00") },
8
- { monthLabel: "February", date: new Date("2021-02-01T00:00:00+01:00") },
9
- { monthLabel: "March", date: new Date("2021-03-01T00:00:00+01:00") },
10
- { monthLabel: "April", date: new Date("2021-04-01T00:00:00+02:00") },
11
- { monthLabel: "May", date: new Date("2021-05-01T00:00:00+02:00") },
12
- { monthLabel: "June", date: new Date("2021-06-01T00:00:00+02:00") },
13
- { monthLabel: "July", date: new Date("2021-07-01T00:00:00+02:00") },
14
- { monthLabel: "August", date: new Date("2021-08-01T00:00:00+02:00") },
15
- { monthLabel: "September", date: new Date("2021-09-01T00:00:00+02:00") },
16
- { monthLabel: "October", date: new Date("2021-10-01T00:00:00+02:00") },
17
- { monthLabel: "November", date: new Date("2021-11-01T00:00:00+01:00") },
18
- { monthLabel: "December", date: new Date("2021-12-01T00:00:00+01:00") },
6
+ expect((0, get_months_1.getMonths)({ year: 2021 }).map((d) => ({ ...d, date: d.date.toUTCString() }))).toStrictEqual([
7
+ { monthLabel: "January", date: new Date("2021-01-01T00:00:00+01:00").toUTCString() },
8
+ { monthLabel: "February", date: new Date("2021-02-01T00:00:00+01:00").toUTCString() },
9
+ { monthLabel: "March", date: new Date("2021-03-01T00:00:00+01:00").toUTCString() },
10
+ { monthLabel: "April", date: new Date("2021-04-01T00:00:00+02:00").toUTCString() },
11
+ { monthLabel: "May", date: new Date("2021-05-01T00:00:00+02:00").toUTCString() },
12
+ { monthLabel: "June", date: new Date("2021-06-01T00:00:00+02:00").toUTCString() },
13
+ { monthLabel: "July", date: new Date("2021-07-01T00:00:00+02:00").toUTCString() },
14
+ { monthLabel: "August", date: new Date("2021-08-01T00:00:00+02:00").toUTCString() },
15
+ { monthLabel: "September", date: new Date("2021-09-01T00:00:00+02:00").toUTCString() },
16
+ { monthLabel: "October", date: new Date("2021-10-01T00:00:00+02:00").toUTCString() },
17
+ { monthLabel: "November", date: new Date("2021-11-01T00:00:00+01:00").toUTCString() },
18
+ { monthLabel: "December", date: new Date("2021-12-01T00:00:00+01:00").toUTCString() },
19
19
  ]);
20
20
  });
21
21
  test("getMonths with custom format", () => {
22
- expect((0, get_months_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("MM") })).toStrictEqual([
23
- { monthLabel: "01", date: new Date("2021-01-01T00:00:00+01:00") },
24
- { monthLabel: "02", date: new Date("2021-02-01T00:00:00+01:00") },
25
- { monthLabel: "03", date: new Date("2021-03-01T00:00:00+01:00") },
26
- { monthLabel: "04", date: new Date("2021-04-01T00:00:00+02:00") },
27
- { monthLabel: "05", date: new Date("2021-05-01T00:00:00+02:00") },
28
- { monthLabel: "06", date: new Date("2021-06-01T00:00:00+02:00") },
29
- { monthLabel: "07", date: new Date("2021-07-01T00:00:00+02:00") },
30
- { monthLabel: "08", date: new Date("2021-08-01T00:00:00+02:00") },
31
- { monthLabel: "09", date: new Date("2021-09-01T00:00:00+02:00") },
32
- { monthLabel: "10", date: new Date("2021-10-01T00:00:00+02:00") },
33
- { monthLabel: "11", date: new Date("2021-11-01T00:00:00+01:00") },
34
- { monthLabel: "12", date: new Date("2021-12-01T00:00:00+01:00") },
22
+ expect((0, get_months_1.getMonths)({ year: 2021, monthLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("MM") }).map((d) => ({
23
+ ...d,
24
+ date: d.date.toUTCString(),
25
+ }))).toStrictEqual([
26
+ { monthLabel: "01", date: new Date("2021-01-01T00:00:00+01:00").toUTCString() },
27
+ { monthLabel: "02", date: new Date("2021-02-01T00:00:00+01:00").toUTCString() },
28
+ { monthLabel: "03", date: new Date("2021-03-01T00:00:00+01:00").toUTCString() },
29
+ { monthLabel: "04", date: new Date("2021-04-01T00:00:00+02:00").toUTCString() },
30
+ { monthLabel: "05", date: new Date("2021-05-01T00:00:00+02:00").toUTCString() },
31
+ { monthLabel: "06", date: new Date("2021-06-01T00:00:00+02:00").toUTCString() },
32
+ { monthLabel: "07", date: new Date("2021-07-01T00:00:00+02:00").toUTCString() },
33
+ { monthLabel: "08", date: new Date("2021-08-01T00:00:00+02:00").toUTCString() },
34
+ { monthLabel: "09", date: new Date("2021-09-01T00:00:00+02:00").toUTCString() },
35
+ { monthLabel: "10", date: new Date("2021-10-01T00:00:00+02:00").toUTCString() },
36
+ { monthLabel: "11", date: new Date("2021-11-01T00:00:00+01:00").toUTCString() },
37
+ { monthLabel: "12", date: new Date("2021-12-01T00:00:00+01:00").toUTCString() },
35
38
  ]);
36
39
  });
@@ -3,11 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const dayjs_en_1 = require("./dayjs-en");
4
4
  const get_years_1 = require("./get-years");
5
5
  test("getYears", () => {
6
- expect((0, get_years_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") })).toStrictEqual([
7
- { yearLabel: "2018", date: new Date("2018-01-01T00:00:00+01:00") },
8
- { yearLabel: "2019", date: new Date("2019-01-01T00:00:00+01:00") },
9
- { yearLabel: "2020", date: new Date("2020-01-01T00:00:00+01:00") },
10
- { yearLabel: "2021", date: new Date("2021-01-01T00:00:00+01:00") },
6
+ expect((0, get_years_1.getYears)({ startYear: new Date("2018-08-15"), endYear: new Date("2021-05-03") }).map((d) => ({
7
+ ...d,
8
+ date: d.date.toUTCString(),
9
+ }))).toStrictEqual([
10
+ { yearLabel: "2018", date: new Date("2018-01-01T00:00:00+01:00").toUTCString() },
11
+ { yearLabel: "2019", date: new Date("2019-01-01T00:00:00+01:00").toUTCString() },
12
+ { yearLabel: "2020", date: new Date("2020-01-01T00:00:00+01:00").toUTCString() },
13
+ { yearLabel: "2021", date: new Date("2021-01-01T00:00:00+01:00").toUTCString() },
11
14
  ]);
12
15
  });
13
16
  test("getYears with custom format", () => {
@@ -15,10 +18,10 @@ test("getYears with custom format", () => {
15
18
  startYear: new Date("2018-08-15"),
16
19
  endYear: new Date("2021-05-03"),
17
20
  yearLabelFormat: (date) => (0, dayjs_en_1.dayjsEn)(date).format("YY"),
18
- })).toStrictEqual([
19
- { yearLabel: "18", date: new Date("2018-01-01T00:00:00+01:00") },
20
- { yearLabel: "19", date: new Date("2019-01-01T00:00:00+01:00") },
21
- { yearLabel: "20", date: new Date("2020-01-01T00:00:00+01:00") },
22
- { yearLabel: "21", date: new Date("2021-01-01T00:00:00+01:00") },
21
+ }).map((d) => ({ ...d, date: d.date.toUTCString() }))).toStrictEqual([
22
+ { yearLabel: "18", date: new Date("2018-01-01T00:00:00+01:00").toUTCString() },
23
+ { yearLabel: "19", date: new Date("2019-01-01T00:00:00+01:00").toUTCString() },
24
+ { yearLabel: "20", date: new Date("2020-01-01T00:00:00+01:00").toUTCString() },
25
+ { yearLabel: "21", date: new Date("2021-01-01T00:00:00+01:00").toUTCString() },
23
26
  ]);
24
27
  });
@@ -2,7 +2,7 @@ export interface IsDateHoveredProps {
2
2
  startDate: Date | null;
3
3
  endDate: Date | null;
4
4
  date: Date;
5
- isDateBlocked(date: Date): boolean;
5
+ isDateBlocked: ((date: Date) => boolean) | undefined;
6
6
  hoveredDate: Date | null;
7
7
  minBookingDays: number;
8
8
  exactMinBookingDays: boolean;