@uxf/datepicker 11.93.3 → 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
  });
@@ -1 +1 @@
1
- export declare function getEach(start: Date, end: Date, type: "day" | "month" | "year", arr?: Date[]): Date[];
1
+ export declare function getEach(start: Date, end: Date, type: "day" | "month" | "year"): Date[];
package/utils/get-each.js CHANGED
@@ -1,14 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEach = getEach;
4
+ const tz_1 = require("@date-fns/tz");
5
+ const date_fns_1 = require("date-fns");
4
6
  const dayjs_en_1 = require("./dayjs-en");
5
- function getEach(start, end, type, arr = [(0, dayjs_en_1.dayjsEn)(start).startOf(type).toDate()]) {
6
- if ((0, dayjs_en_1.dayjsEn)(start).isAfter(end, type)) {
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);
15
+ }
16
+ }
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);
25
+ }
26
+ }
27
+ function getEach(start, end, type) {
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) {
7
31
  throw new Error("start must precede end");
8
32
  }
9
- const next = (0, dayjs_en_1.dayjsEn)(start).add(1, type).startOf(type).toDate();
10
- if ((0, dayjs_en_1.dayjsEn)(next).isAfter(end, type)) {
11
- return arr;
33
+ const results = [];
34
+ let current = startOfStart;
35
+ while (current <= startOfEnd) {
36
+ results.push(current);
37
+ current = getNext(current, type);
12
38
  }
13
- return getEach(next, end, type, arr.concat(next));
39
+ return results;
14
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;
@@ -1,39 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateHovered = isDateHovered;
4
+ const tz_1 = require("@date-fns/tz");
5
+ const date_fns_1 = require("date-fns");
4
6
  const dayjs_en_1 = require("./dayjs-en");
5
7
  const get_each_1 = require("./get-each");
8
+ function isBetween(date, start, end) {
9
+ return (0, date_fns_1.isAfter)(date, start) && (0, date_fns_1.isBefore)(date, end);
10
+ }
11
+ // eslint-disable-next-line complexity
6
12
  function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
13
+ const dateTZ = new tz_1.TZDate(date, dayjs_en_1.DEFAULT_TIMEZONE);
14
+ const hoveredDateTZ = hoveredDate ? new tz_1.TZDate(hoveredDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
7
15
  if (
8
16
  // exact min booking days
9
- hoveredDate &&
17
+ hoveredDateTZ &&
10
18
  minBookingDays > 1 &&
11
19
  exactMinBookingDays &&
12
- (0, dayjs_en_1.dayjsEn)(date).isBetween(hoveredDate, (0, dayjs_en_1.dayjsEn)(hoveredDate).add(minBookingDays - 1, "day"))) {
13
- return !(0, get_each_1.getEach)(hoveredDate, (0, dayjs_en_1.dayjsEn)(hoveredDate)
14
- .add(minBookingDays - 1, "day")
15
- .toDate(), "day").some((d) => isDateBlocked(d));
20
+ isBetween(dateTZ, hoveredDateTZ, (0, date_fns_1.addDays)(hoveredDateTZ, minBookingDays - 1))) {
21
+ if (isDateBlocked) {
22
+ return !(0, get_each_1.getEach)(hoveredDateTZ, (0, date_fns_1.addDays)(hoveredDateTZ, minBookingDays - 1), "day").some((d) => isDateBlocked(d));
23
+ }
24
+ return true;
16
25
  }
17
- else if (
26
+ const startDateTZ = startDate ? new tz_1.TZDate(startDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
27
+ const endDateTZ = endDate ? new tz_1.TZDate(endDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
28
+ if (
18
29
  // min booking days
19
- startDate &&
20
- !endDate &&
21
- hoveredDate &&
22
- (0, dayjs_en_1.dayjsEn)(date).isBetween(startDate, (0, dayjs_en_1.dayjsEn)(startDate).add(minBookingDays - 1, "day")) &&
23
- (0, dayjs_en_1.dayjsEn)(startDate).isSame(hoveredDate, "days") &&
24
- minBookingDays > 1) {
25
- return !(0, get_each_1.getEach)(startDate, (0, dayjs_en_1.dayjsEn)(startDate)
26
- .add(minBookingDays - 1, "day")
27
- .toDate(), "day").some((d) => isDateBlocked(d));
30
+ startDateTZ &&
31
+ !endDateTZ &&
32
+ hoveredDateTZ &&
33
+ minBookingDays > 1 &&
34
+ isBetween(dateTZ, startDateTZ, (0, date_fns_1.addDays)(startDateTZ, minBookingDays - 1)) &&
35
+ (0, date_fns_1.isSameDay)(startDateTZ, hoveredDateTZ)) {
36
+ if (isDateBlocked) {
37
+ return !(0, get_each_1.getEach)(startDateTZ, (0, date_fns_1.addDays)(startDateTZ, minBookingDays - 1), "day").some((d) => isDateBlocked(d));
38
+ }
39
+ return true;
28
40
  }
29
- else if (
41
+ if (
30
42
  // normal
31
- startDate &&
32
- !endDate &&
33
- hoveredDate &&
34
- !(0, dayjs_en_1.dayjsEn)(hoveredDate).isBefore(startDate) &&
35
- (0, dayjs_en_1.dayjsEn)(date).isBetween(startDate, hoveredDate)) {
36
- return !(0, get_each_1.getEach)(startDate, hoveredDate, "day").some((d) => isDateBlocked(d));
43
+ startDateTZ &&
44
+ !endDateTZ &&
45
+ hoveredDateTZ &&
46
+ !(0, date_fns_1.isBefore)(hoveredDateTZ, startDateTZ) &&
47
+ isBetween(dateTZ, startDateTZ, hoveredDateTZ)) {
48
+ if (isDateBlocked) {
49
+ return !(0, get_each_1.getEach)(startDateTZ, hoveredDateTZ, "day").some((d) => isDateBlocked(d));
50
+ }
51
+ return true;
37
52
  }
38
53
  return false;
39
54
  }
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateInsideRange = isDateInsideRange;
4
+ const tz_1 = require("@date-fns/tz");
5
+ const date_fns_1 = require("date-fns");
4
6
  const dayjs_en_1 = require("./dayjs-en");
7
+ function isBetween(date, start, end) {
8
+ return (0, date_fns_1.isAfter)(date, start) && (0, date_fns_1.isBefore)(date, end);
9
+ }
5
10
  function isDateInsideRange(date, startDate, endDate) {
6
11
  if (startDate && endDate) {
7
- return (0, dayjs_en_1.dayjsEn)(date).isBetween(startDate, endDate);
12
+ return isBetween(new tz_1.TZDate(date, dayjs_en_1.DEFAULT_TIMEZONE), new tz_1.TZDate(startDate, dayjs_en_1.DEFAULT_TIMEZONE), new tz_1.TZDate(endDate, dayjs_en_1.DEFAULT_TIMEZONE));
8
13
  }
9
14
  return false;
10
15
  }
@@ -1,7 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFirstOrLastSelectedDate = isFirstOrLastSelectedDate;
4
+ const tz_1 = require("@date-fns/tz");
5
+ const date_fns_1 = require("date-fns");
4
6
  const dayjs_en_1 = require("./dayjs-en");
5
7
  function isFirstOrLastSelectedDate(date, startDate, endDate) {
6
- return Boolean((startDate && (0, dayjs_en_1.dayjsEn)(date).isSame(startDate, "day")) || (endDate && (0, dayjs_en_1.dayjsEn)(date).isSame(endDate, "day")));
8
+ if (!startDate && !endDate) {
9
+ return false;
10
+ }
11
+ const dateTZ = new tz_1.TZDate(date, dayjs_en_1.DEFAULT_TIMEZONE);
12
+ const startDateTZ = startDate ? new tz_1.TZDate(startDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
13
+ const endDateTZ = endDate ? new tz_1.TZDate(endDate, dayjs_en_1.DEFAULT_TIMEZONE) : null;
14
+ return Boolean((startDateTZ && (0, date_fns_1.isSameDay)(dateTZ, startDateTZ)) || (endDateTZ && (0, date_fns_1.isSameDay)(dateTZ, endDateTZ)));
7
15
  }