colombian-holidays 5.0.2 → 5.0.5
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/README.md +3 -5
- package/dist/index.d.mts +62 -0
- package/dist/index.d.ts +49 -11
- package/dist/index.js +334 -44
- package/dist/index.mjs +295 -0
- package/package.json +15 -16
- package/dist/helpers.d.ts +0 -15
- package/dist/helpers.js +0 -50
- package/dist/helpers.js.map +0 -1
- package/dist/holidays.d.ts +0 -3
- package/dist/holidays.js +0 -147
- package/dist/holidays.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -23
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/utils/getHoliday.d.ts +0 -7
- package/dist/utils/getHoliday.js +0 -24
- package/dist/utils/getHoliday.js.map +0 -1
- package/dist/utils/getHolidaysByYear.d.ts +0 -7
- package/dist/utils/getHolidaysByYear.js +0 -29
- package/dist/utils/getHolidaysByYear.js.map +0 -1
- package/dist/utils/helpers.d.ts +0 -1
- package/dist/utils/helpers.js +0 -10
- package/dist/utils/helpers.js.map +0 -1
- package/dist/utils/holidaysWithinInterval.d.ts +0 -16
- package/dist/utils/holidaysWithinInterval.js +0 -23
- package/dist/utils/holidaysWithinInterval.js.map +0 -1
- package/dist/utils/isHoliday.d.ts +0 -1
- package/dist/utils/isHoliday.js +0 -13
- package/dist/utils/isHoliday.js.map +0 -1
package/README.md
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# Colombian Holidays 🎆
|
2
2
|
|
3
3
|
[](https://badge.fury.io/js/colombian-holidays)
|
4
|
-
[](https://codecov.io/gh/MauricioRobayo/colombian-holidays)
|
5
|
-
[](https://www.codefactor.io/repository/github/mauriciorobayo/colombian-holidays)
|
6
|
-
[](git@github.com:MauricioRobayo/colombian-holidays.git)
|
7
4
|
|
8
5
|
TypeScript module to calculate colombian holidays for any given year.
|
9
6
|
|
@@ -280,9 +277,10 @@ This function is equivalent to calling:
|
|
280
277
|
colombianHolidays({ year: 2025 });
|
281
278
|
```
|
282
279
|
|
283
|
-
But
|
280
|
+
But uses an in-memory cache.
|
284
281
|
|
285
|
-
|
282
|
+
> [!TIP]
|
283
|
+
> Use `getHolidaysByYear` instead of `colombianHolidays` when possible. It includes built-in caching, which improves performance and avoids redundant computations when accessing holidays by year. It is used under the hood by all other helpers, providing a shared in-memory cache.
|
286
284
|
|
287
285
|
### isHoliday
|
288
286
|
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
interface BasicHoliday {
|
2
|
+
name: {
|
3
|
+
en: string;
|
4
|
+
es: string;
|
5
|
+
};
|
6
|
+
nextMonday: boolean;
|
7
|
+
}
|
8
|
+
interface ColombianHoliday extends BasicHoliday {
|
9
|
+
date: string;
|
10
|
+
celebrationDate: string;
|
11
|
+
}
|
12
|
+
interface ColombianHolidayWithNativeDate extends BasicHoliday {
|
13
|
+
date: Date;
|
14
|
+
celebrationDate: Date;
|
15
|
+
}
|
16
|
+
|
17
|
+
declare function getHolidaysForYear(year: number, options?: {
|
18
|
+
valueAsDate: false | undefined;
|
19
|
+
}): ColombianHoliday[];
|
20
|
+
declare function getHolidaysForYear(year: number, options?: {
|
21
|
+
valueAsDate: true;
|
22
|
+
}): ColombianHolidayWithNativeDate[];
|
23
|
+
|
24
|
+
declare function isHoliday(date: Date): boolean;
|
25
|
+
|
26
|
+
declare function holidaysWithinInterval(options: {
|
27
|
+
start: Date;
|
28
|
+
end: Date;
|
29
|
+
valueAsDate: false | undefined;
|
30
|
+
}): ColombianHoliday[];
|
31
|
+
declare function holidaysWithinInterval(options: {
|
32
|
+
start: Date;
|
33
|
+
end: Date;
|
34
|
+
valueAsDate: true;
|
35
|
+
}): ColombianHolidayWithNativeDate[];
|
36
|
+
declare function holidaysWithinInterval(options: {
|
37
|
+
start: Date;
|
38
|
+
end: Date;
|
39
|
+
valueAsDate?: boolean;
|
40
|
+
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
41
|
+
|
42
|
+
declare const FIRST_HOLIDAY_YEAR = 1583;
|
43
|
+
declare const LAST_HOLIDAY_YEAR = 4099;
|
44
|
+
type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
45
|
+
type Month = MonthNumbers | Omit<number, MonthNumbers>;
|
46
|
+
declare function colombianHolidays(options?: undefined | {
|
47
|
+
year?: number;
|
48
|
+
month?: Month;
|
49
|
+
valueAsDate: false | undefined;
|
50
|
+
}): ColombianHoliday[];
|
51
|
+
declare function colombianHolidays(options?: {
|
52
|
+
year?: number;
|
53
|
+
month?: Month;
|
54
|
+
valueAsDate: true;
|
55
|
+
}): ColombianHolidayWithNativeDate[];
|
56
|
+
declare function colombianHolidays(options?: {
|
57
|
+
year?: number;
|
58
|
+
month?: Month;
|
59
|
+
valueAsDate?: boolean;
|
60
|
+
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
61
|
+
|
62
|
+
export { FIRST_HOLIDAY_YEAR, LAST_HOLIDAY_YEAR, type Month, colombianHolidays, colombianHolidays as default, getHolidaysForYear, holidaysWithinInterval, isHoliday };
|
package/dist/index.d.ts
CHANGED
@@ -1,24 +1,62 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
interface BasicHoliday {
|
2
|
+
name: {
|
3
|
+
en: string;
|
4
|
+
es: string;
|
5
|
+
};
|
6
|
+
nextMonday: boolean;
|
7
|
+
}
|
8
|
+
interface ColombianHoliday extends BasicHoliday {
|
9
|
+
date: string;
|
10
|
+
celebrationDate: string;
|
11
|
+
}
|
12
|
+
interface ColombianHolidayWithNativeDate extends BasicHoliday {
|
13
|
+
date: Date;
|
14
|
+
celebrationDate: Date;
|
15
|
+
}
|
16
|
+
|
17
|
+
declare function getHolidaysForYear(year: number, options?: {
|
18
|
+
valueAsDate: false | undefined;
|
19
|
+
}): ColombianHoliday[];
|
20
|
+
declare function getHolidaysForYear(year: number, options?: {
|
21
|
+
valueAsDate: true;
|
22
|
+
}): ColombianHolidayWithNativeDate[];
|
23
|
+
|
24
|
+
declare function isHoliday(date: Date): boolean;
|
25
|
+
|
26
|
+
declare function holidaysWithinInterval(options: {
|
27
|
+
start: Date;
|
28
|
+
end: Date;
|
29
|
+
valueAsDate: false | undefined;
|
30
|
+
}): ColombianHoliday[];
|
31
|
+
declare function holidaysWithinInterval(options: {
|
32
|
+
start: Date;
|
33
|
+
end: Date;
|
34
|
+
valueAsDate: true;
|
35
|
+
}): ColombianHolidayWithNativeDate[];
|
36
|
+
declare function holidaysWithinInterval(options: {
|
37
|
+
start: Date;
|
38
|
+
end: Date;
|
39
|
+
valueAsDate?: boolean;
|
40
|
+
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
41
|
+
|
42
|
+
declare const FIRST_HOLIDAY_YEAR = 1583;
|
43
|
+
declare const LAST_HOLIDAY_YEAR = 4099;
|
4
44
|
type MonthNumbers = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
5
|
-
|
6
|
-
|
45
|
+
type Month = MonthNumbers | Omit<number, MonthNumbers>;
|
46
|
+
declare function colombianHolidays(options?: undefined | {
|
7
47
|
year?: number;
|
8
48
|
month?: Month;
|
9
49
|
valueAsDate: false | undefined;
|
10
50
|
}): ColombianHoliday[];
|
11
|
-
|
51
|
+
declare function colombianHolidays(options?: {
|
12
52
|
year?: number;
|
13
53
|
month?: Month;
|
14
54
|
valueAsDate: true;
|
15
55
|
}): ColombianHolidayWithNativeDate[];
|
16
|
-
|
56
|
+
declare function colombianHolidays(options?: {
|
17
57
|
year?: number;
|
18
58
|
month?: Month;
|
19
59
|
valueAsDate?: boolean;
|
20
60
|
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
21
|
-
|
22
|
-
export { getHolidaysForYear
|
23
|
-
export { isHoliday } from "./utils/isHoliday";
|
24
|
-
export { holidaysWithinInterval } from "./utils/holidaysWithinInterval";
|
61
|
+
|
62
|
+
export { FIRST_HOLIDAY_YEAR, LAST_HOLIDAY_YEAR, type Month, colombianHolidays, colombianHolidays as default, getHolidaysForYear, holidaysWithinInterval, isHoliday };
|
package/dist/index.js
CHANGED
@@ -1,47 +1,337 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
4
11
|
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
|
30
|
+
// src/index.ts
|
31
|
+
var index_exports = {};
|
32
|
+
__export(index_exports, {
|
33
|
+
FIRST_HOLIDAY_YEAR: () => FIRST_HOLIDAY_YEAR,
|
34
|
+
LAST_HOLIDAY_YEAR: () => LAST_HOLIDAY_YEAR,
|
35
|
+
colombianHolidays: () => colombianHolidays,
|
36
|
+
default: () => index_default,
|
37
|
+
getHolidaysForYear: () => getHolidaysForYear,
|
38
|
+
holidaysWithinInterval: () => holidaysWithinInterval,
|
39
|
+
isHoliday: () => isHoliday
|
40
|
+
});
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
42
|
+
|
43
|
+
// src/helpers.ts
|
44
|
+
var import_pascua = __toESM(require("pascua"));
|
45
|
+
var NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
|
46
|
+
function getNextDayOfWeek(date, dayOfWeek) {
|
47
|
+
const resultDate = new Date(date);
|
48
|
+
resultDate.setUTCDate(
|
49
|
+
date.getUTCDate() + (7 + dayOfWeek - date.getUTCDay()) % 7
|
50
|
+
);
|
51
|
+
return resultDate;
|
52
|
+
}
|
53
|
+
function getNextMonday(date) {
|
54
|
+
const MONDAY = 1;
|
55
|
+
return getNextDayOfWeek(date, MONDAY);
|
56
|
+
}
|
57
|
+
function isEasterHoliday(holiday) {
|
58
|
+
return "offset" in holiday;
|
59
|
+
}
|
60
|
+
function getHolidayDate(holiday, year) {
|
61
|
+
if (isEasterHoliday(holiday)) {
|
62
|
+
const { month, day } = (0, import_pascua.default)(year);
|
63
|
+
const date = new Date(generateUtcStringFromDateParts(year, month, 1));
|
64
|
+
date.setUTCDate(day + holiday.offset);
|
65
|
+
return date;
|
66
|
+
}
|
67
|
+
return new Date(
|
68
|
+
generateUtcStringFromDateParts(year, holiday.month, holiday.day)
|
69
|
+
);
|
70
|
+
}
|
71
|
+
function generateUtcStringFromDateParts(year, month, day) {
|
72
|
+
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(
|
73
|
+
2,
|
74
|
+
"0"
|
75
|
+
)}`;
|
76
|
+
}
|
77
|
+
function getHoliday(holiday, {
|
78
|
+
year = (/* @__PURE__ */ new Date()).getUTCFullYear(),
|
79
|
+
valueAsDate = false
|
80
|
+
} = {}) {
|
81
|
+
const holidayDate = getHolidayDate(holiday, year);
|
82
|
+
const celebrationDate = year >= NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday ? getNextMonday(holidayDate) : holidayDate;
|
83
|
+
return {
|
84
|
+
date: valueAsDate ? holidayDate : holidayDate.toISOString().slice(0, 10),
|
85
|
+
celebrationDate: valueAsDate ? celebrationDate : celebrationDate.toISOString().slice(0, 10),
|
86
|
+
name: holiday.name,
|
87
|
+
nextMonday: year >= NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday
|
88
|
+
};
|
89
|
+
}
|
90
|
+
var helpers_default = getHoliday;
|
91
|
+
|
92
|
+
// src/holidays.ts
|
93
|
+
var dateHolidays = [
|
94
|
+
{
|
95
|
+
month: 1,
|
96
|
+
day: 1,
|
97
|
+
name: {
|
98
|
+
es: "A\xF1o Nuevo",
|
99
|
+
en: "New Year's Day"
|
100
|
+
},
|
101
|
+
nextMonday: false
|
102
|
+
},
|
103
|
+
{
|
104
|
+
month: 1,
|
105
|
+
day: 6,
|
106
|
+
name: {
|
107
|
+
es: "Reyes Magos",
|
108
|
+
en: "Epiphany"
|
109
|
+
},
|
110
|
+
nextMonday: true
|
111
|
+
},
|
112
|
+
{
|
113
|
+
month: 3,
|
114
|
+
day: 19,
|
115
|
+
name: {
|
116
|
+
es: "San Jos\xE9",
|
117
|
+
en: "Saint Joseph's Day"
|
118
|
+
},
|
119
|
+
nextMonday: true
|
120
|
+
},
|
121
|
+
{
|
122
|
+
month: 5,
|
123
|
+
day: 1,
|
124
|
+
name: {
|
125
|
+
es: "D\xEDa del Trabajo",
|
126
|
+
en: "Labour Day"
|
127
|
+
},
|
128
|
+
nextMonday: false
|
129
|
+
},
|
130
|
+
{
|
131
|
+
month: 6,
|
132
|
+
day: 29,
|
133
|
+
name: {
|
134
|
+
es: "San Pedro y San Pablo",
|
135
|
+
en: "Saint Peter and Saint Paul"
|
136
|
+
},
|
137
|
+
nextMonday: true
|
138
|
+
},
|
139
|
+
{
|
140
|
+
month: 7,
|
141
|
+
day: 20,
|
142
|
+
name: {
|
143
|
+
es: "Grito de la Independencia",
|
144
|
+
en: "Declaration of Independence"
|
145
|
+
},
|
146
|
+
nextMonday: false
|
147
|
+
},
|
148
|
+
{
|
149
|
+
month: 8,
|
150
|
+
day: 7,
|
151
|
+
name: {
|
152
|
+
es: "Batalla de Boyac\xE1",
|
153
|
+
en: "Battle of Boyac\xE1"
|
154
|
+
},
|
155
|
+
nextMonday: false
|
156
|
+
},
|
157
|
+
{
|
158
|
+
month: 8,
|
159
|
+
day: 15,
|
160
|
+
name: {
|
161
|
+
es: "Asunci\xF3n de la Virgen",
|
162
|
+
en: "Assumption of Mary"
|
163
|
+
},
|
164
|
+
nextMonday: true
|
165
|
+
},
|
166
|
+
{
|
167
|
+
month: 10,
|
168
|
+
day: 12,
|
169
|
+
name: {
|
170
|
+
es: "D\xEDa de la Raza",
|
171
|
+
en: "Columbus Day"
|
172
|
+
},
|
173
|
+
nextMonday: true
|
174
|
+
},
|
175
|
+
{
|
176
|
+
month: 11,
|
177
|
+
day: 1,
|
178
|
+
name: {
|
179
|
+
es: "Todos los Santos",
|
180
|
+
en: "All Saints\u2019 Day"
|
181
|
+
},
|
182
|
+
nextMonday: true
|
183
|
+
},
|
184
|
+
{
|
185
|
+
month: 11,
|
186
|
+
day: 11,
|
187
|
+
name: { es: "Independencia de Cartagena", en: "Independence of Cartagena" },
|
188
|
+
nextMonday: true
|
189
|
+
},
|
190
|
+
{
|
191
|
+
month: 12,
|
192
|
+
day: 8,
|
193
|
+
name: { es: "Inmaculada Concepci\xF3n", en: "Immaculate Conception" },
|
194
|
+
nextMonday: false
|
195
|
+
},
|
196
|
+
{
|
197
|
+
month: 12,
|
198
|
+
day: 25,
|
199
|
+
name: { es: "Navidad", en: "Christmas" },
|
200
|
+
nextMonday: false
|
201
|
+
}
|
202
|
+
];
|
203
|
+
var easterHolidays = [
|
204
|
+
{
|
205
|
+
offset: -3,
|
206
|
+
name: { es: "Jueves Santo", en: "Maundy Thursday" },
|
207
|
+
nextMonday: false
|
208
|
+
},
|
209
|
+
{
|
210
|
+
offset: -2,
|
211
|
+
name: { es: "Viernes Santo", en: "Good Friday" },
|
212
|
+
nextMonday: false
|
213
|
+
},
|
214
|
+
{
|
215
|
+
offset: 39,
|
216
|
+
name: { es: "Ascensi\xF3n del Se\xF1or", en: "Ascension of Jesus" },
|
217
|
+
nextMonday: true
|
218
|
+
},
|
219
|
+
{
|
220
|
+
offset: 60,
|
221
|
+
name: { es: "Corpus Christi", en: "Corpus Christi" },
|
222
|
+
nextMonday: true
|
223
|
+
},
|
224
|
+
{
|
225
|
+
offset: 68,
|
226
|
+
name: { es: "Sagrado Coraz\xF3n de Jes\xFAs", en: "Sacred Heart" },
|
227
|
+
nextMonday: true
|
228
|
+
}
|
229
|
+
];
|
230
|
+
var holidays_default = [...dateHolidays, ...easterHolidays];
|
231
|
+
|
232
|
+
// src/utils/getHolidaysByYear.ts
|
233
|
+
var holidaysWithNativeDateCache = /* @__PURE__ */ new Map();
|
234
|
+
var holidaysCache = /* @__PURE__ */ new Map();
|
235
|
+
function getHolidaysForYear(year, { valueAsDate = false } = {}) {
|
236
|
+
if (valueAsDate) {
|
237
|
+
const cachedHolidays2 = holidaysWithNativeDateCache.get(year);
|
238
|
+
if (cachedHolidays2) {
|
239
|
+
return cachedHolidays2;
|
240
|
+
}
|
241
|
+
const holidays2 = index_default({ year, valueAsDate });
|
242
|
+
holidaysWithNativeDateCache.set(year, holidays2);
|
243
|
+
return holidays2;
|
244
|
+
}
|
245
|
+
const cachedHolidays = holidaysCache.get(year);
|
246
|
+
if (cachedHolidays) {
|
247
|
+
return cachedHolidays;
|
248
|
+
}
|
249
|
+
const holidays = index_default({ year, valueAsDate });
|
250
|
+
holidaysCache.set(year, holidays);
|
251
|
+
return holidays;
|
252
|
+
}
|
253
|
+
|
254
|
+
// src/utils/helpers.ts
|
255
|
+
function isSameDate(date1, date2) {
|
256
|
+
return date1.getUTCDate() === date2.getUTCDate() && date1.getUTCMonth() === date2.getUTCMonth() && date1.getUTCFullYear() === date2.getUTCFullYear();
|
257
|
+
}
|
258
|
+
|
259
|
+
// src/utils/isHoliday.ts
|
260
|
+
function isHoliday(date) {
|
261
|
+
const holidays = getHolidaysForYear(date.getUTCFullYear(), {
|
262
|
+
valueAsDate: true
|
263
|
+
});
|
264
|
+
return holidays.some(
|
265
|
+
({ celebrationDate }) => isSameDate(celebrationDate, date)
|
266
|
+
);
|
267
|
+
}
|
268
|
+
|
269
|
+
// src/utils/holidaysWithinInterval.ts
|
270
|
+
function holidaysWithinInterval({
|
271
|
+
start,
|
272
|
+
end,
|
273
|
+
valueAsDate = false
|
274
|
+
}) {
|
275
|
+
if (start >= end) {
|
276
|
+
throw new Error("end date should be greater than start date");
|
277
|
+
}
|
278
|
+
const yearEnd = end.getUTCFullYear();
|
279
|
+
const yearStart = start.getUTCFullYear();
|
280
|
+
const holidays = Array.from(
|
281
|
+
{ length: yearEnd - yearStart + 1 },
|
282
|
+
(_, i) => getHolidaysForYear(i + yearStart, { valueAsDate: true })
|
283
|
+
).flat();
|
284
|
+
const holidaysWithin = holidays.filter(
|
285
|
+
({ celebrationDate }) => celebrationDate >= start && celebrationDate <= end
|
286
|
+
);
|
287
|
+
if (valueAsDate) {
|
288
|
+
return holidaysWithin;
|
289
|
+
}
|
290
|
+
return holidaysWithin.map((holiday) => ({
|
291
|
+
...holiday,
|
292
|
+
date: holiday.date.toISOString().slice(0, 10),
|
293
|
+
celebrationDate: holiday.celebrationDate.toISOString().slice(0, 10)
|
294
|
+
}));
|
295
|
+
}
|
296
|
+
|
297
|
+
// src/index.ts
|
298
|
+
var FIRST_HOLIDAY_YEAR = 1583;
|
299
|
+
var LAST_HOLIDAY_YEAR = 4099;
|
300
|
+
function colombianHolidays({
|
301
|
+
year = (/* @__PURE__ */ new Date()).getUTCFullYear(),
|
302
|
+
month,
|
303
|
+
valueAsDate = false
|
304
|
+
} = {}) {
|
305
|
+
if (year < FIRST_HOLIDAY_YEAR || year > LAST_HOLIDAY_YEAR) {
|
306
|
+
throw new Error(
|
307
|
+
`The year should be between ${FIRST_HOLIDAY_YEAR} and ${LAST_HOLIDAY_YEAR}`
|
308
|
+
);
|
309
|
+
}
|
310
|
+
return holidays_default.map((holiday) => helpers_default(holiday, { year, valueAsDate })).filter((holiday) => {
|
311
|
+
if (month === void 0) {
|
312
|
+
return true;
|
15
313
|
}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
exports.default = colombianHolidays;
|
41
|
-
var getHolidaysByYear_1 = require("./utils/getHolidaysByYear");
|
42
|
-
Object.defineProperty(exports, "getHolidaysForYear", { enumerable: true, get: function () { return getHolidaysByYear_1.getHolidaysForYear; } });
|
43
|
-
var isHoliday_1 = require("./utils/isHoliday");
|
44
|
-
Object.defineProperty(exports, "isHoliday", { enumerable: true, get: function () { return isHoliday_1.isHoliday; } });
|
45
|
-
var holidaysWithinInterval_1 = require("./utils/holidaysWithinInterval");
|
46
|
-
Object.defineProperty(exports, "holidaysWithinInterval", { enumerable: true, get: function () { return holidaysWithinInterval_1.holidaysWithinInterval; } });
|
47
|
-
//# sourceMappingURL=index.js.map
|
314
|
+
if (typeof holiday.celebrationDate === "string") {
|
315
|
+
return Number(holiday.celebrationDate.slice(5, 7)) === month;
|
316
|
+
}
|
317
|
+
return holiday.celebrationDate.getUTCMonth() + 1 === month;
|
318
|
+
}).sort((a, b) => {
|
319
|
+
if (a.celebrationDate instanceof Date && b.celebrationDate instanceof Date) {
|
320
|
+
return a.celebrationDate.getTime() - b.celebrationDate.getTime();
|
321
|
+
}
|
322
|
+
if (typeof a.celebrationDate === "string" && typeof b.celebrationDate === "string") {
|
323
|
+
return a.celebrationDate.localeCompare(b.celebrationDate);
|
324
|
+
}
|
325
|
+
throw new Error("Invariant violation: this state is not possible.");
|
326
|
+
});
|
327
|
+
}
|
328
|
+
var index_default = colombianHolidays;
|
329
|
+
// Annotate the CommonJS export names for ESM import in node:
|
330
|
+
0 && (module.exports = {
|
331
|
+
FIRST_HOLIDAY_YEAR,
|
332
|
+
LAST_HOLIDAY_YEAR,
|
333
|
+
colombianHolidays,
|
334
|
+
getHolidaysForYear,
|
335
|
+
holidaysWithinInterval,
|
336
|
+
isHoliday
|
337
|
+
});
|