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/dist/index.mjs ADDED
@@ -0,0 +1,295 @@
1
+ // src/helpers.ts
2
+ import pascua from "pascua";
3
+ var NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
4
+ function getNextDayOfWeek(date, dayOfWeek) {
5
+ const resultDate = new Date(date);
6
+ resultDate.setUTCDate(
7
+ date.getUTCDate() + (7 + dayOfWeek - date.getUTCDay()) % 7
8
+ );
9
+ return resultDate;
10
+ }
11
+ function getNextMonday(date) {
12
+ const MONDAY = 1;
13
+ return getNextDayOfWeek(date, MONDAY);
14
+ }
15
+ function isEasterHoliday(holiday) {
16
+ return "offset" in holiday;
17
+ }
18
+ function getHolidayDate(holiday, year) {
19
+ if (isEasterHoliday(holiday)) {
20
+ const { month, day } = pascua(year);
21
+ const date = new Date(generateUtcStringFromDateParts(year, month, 1));
22
+ date.setUTCDate(day + holiday.offset);
23
+ return date;
24
+ }
25
+ return new Date(
26
+ generateUtcStringFromDateParts(year, holiday.month, holiday.day)
27
+ );
28
+ }
29
+ function generateUtcStringFromDateParts(year, month, day) {
30
+ return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(
31
+ 2,
32
+ "0"
33
+ )}`;
34
+ }
35
+ function getHoliday(holiday, {
36
+ year = (/* @__PURE__ */ new Date()).getUTCFullYear(),
37
+ valueAsDate = false
38
+ } = {}) {
39
+ const holidayDate = getHolidayDate(holiday, year);
40
+ const celebrationDate = year >= NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday ? getNextMonday(holidayDate) : holidayDate;
41
+ return {
42
+ date: valueAsDate ? holidayDate : holidayDate.toISOString().slice(0, 10),
43
+ celebrationDate: valueAsDate ? celebrationDate : celebrationDate.toISOString().slice(0, 10),
44
+ name: holiday.name,
45
+ nextMonday: year >= NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday
46
+ };
47
+ }
48
+ var helpers_default = getHoliday;
49
+
50
+ // src/holidays.ts
51
+ var dateHolidays = [
52
+ {
53
+ month: 1,
54
+ day: 1,
55
+ name: {
56
+ es: "A\xF1o Nuevo",
57
+ en: "New Year's Day"
58
+ },
59
+ nextMonday: false
60
+ },
61
+ {
62
+ month: 1,
63
+ day: 6,
64
+ name: {
65
+ es: "Reyes Magos",
66
+ en: "Epiphany"
67
+ },
68
+ nextMonday: true
69
+ },
70
+ {
71
+ month: 3,
72
+ day: 19,
73
+ name: {
74
+ es: "San Jos\xE9",
75
+ en: "Saint Joseph's Day"
76
+ },
77
+ nextMonday: true
78
+ },
79
+ {
80
+ month: 5,
81
+ day: 1,
82
+ name: {
83
+ es: "D\xEDa del Trabajo",
84
+ en: "Labour Day"
85
+ },
86
+ nextMonday: false
87
+ },
88
+ {
89
+ month: 6,
90
+ day: 29,
91
+ name: {
92
+ es: "San Pedro y San Pablo",
93
+ en: "Saint Peter and Saint Paul"
94
+ },
95
+ nextMonday: true
96
+ },
97
+ {
98
+ month: 7,
99
+ day: 20,
100
+ name: {
101
+ es: "Grito de la Independencia",
102
+ en: "Declaration of Independence"
103
+ },
104
+ nextMonday: false
105
+ },
106
+ {
107
+ month: 8,
108
+ day: 7,
109
+ name: {
110
+ es: "Batalla de Boyac\xE1",
111
+ en: "Battle of Boyac\xE1"
112
+ },
113
+ nextMonday: false
114
+ },
115
+ {
116
+ month: 8,
117
+ day: 15,
118
+ name: {
119
+ es: "Asunci\xF3n de la Virgen",
120
+ en: "Assumption of Mary"
121
+ },
122
+ nextMonday: true
123
+ },
124
+ {
125
+ month: 10,
126
+ day: 12,
127
+ name: {
128
+ es: "D\xEDa de la Raza",
129
+ en: "Columbus Day"
130
+ },
131
+ nextMonday: true
132
+ },
133
+ {
134
+ month: 11,
135
+ day: 1,
136
+ name: {
137
+ es: "Todos los Santos",
138
+ en: "All Saints\u2019 Day"
139
+ },
140
+ nextMonday: true
141
+ },
142
+ {
143
+ month: 11,
144
+ day: 11,
145
+ name: { es: "Independencia de Cartagena", en: "Independence of Cartagena" },
146
+ nextMonday: true
147
+ },
148
+ {
149
+ month: 12,
150
+ day: 8,
151
+ name: { es: "Inmaculada Concepci\xF3n", en: "Immaculate Conception" },
152
+ nextMonday: false
153
+ },
154
+ {
155
+ month: 12,
156
+ day: 25,
157
+ name: { es: "Navidad", en: "Christmas" },
158
+ nextMonday: false
159
+ }
160
+ ];
161
+ var easterHolidays = [
162
+ {
163
+ offset: -3,
164
+ name: { es: "Jueves Santo", en: "Maundy Thursday" },
165
+ nextMonday: false
166
+ },
167
+ {
168
+ offset: -2,
169
+ name: { es: "Viernes Santo", en: "Good Friday" },
170
+ nextMonday: false
171
+ },
172
+ {
173
+ offset: 39,
174
+ name: { es: "Ascensi\xF3n del Se\xF1or", en: "Ascension of Jesus" },
175
+ nextMonday: true
176
+ },
177
+ {
178
+ offset: 60,
179
+ name: { es: "Corpus Christi", en: "Corpus Christi" },
180
+ nextMonday: true
181
+ },
182
+ {
183
+ offset: 68,
184
+ name: { es: "Sagrado Coraz\xF3n de Jes\xFAs", en: "Sacred Heart" },
185
+ nextMonday: true
186
+ }
187
+ ];
188
+ var holidays_default = [...dateHolidays, ...easterHolidays];
189
+
190
+ // src/utils/getHolidaysByYear.ts
191
+ var holidaysWithNativeDateCache = /* @__PURE__ */ new Map();
192
+ var holidaysCache = /* @__PURE__ */ new Map();
193
+ function getHolidaysForYear(year, { valueAsDate = false } = {}) {
194
+ if (valueAsDate) {
195
+ const cachedHolidays2 = holidaysWithNativeDateCache.get(year);
196
+ if (cachedHolidays2) {
197
+ return cachedHolidays2;
198
+ }
199
+ const holidays2 = index_default({ year, valueAsDate });
200
+ holidaysWithNativeDateCache.set(year, holidays2);
201
+ return holidays2;
202
+ }
203
+ const cachedHolidays = holidaysCache.get(year);
204
+ if (cachedHolidays) {
205
+ return cachedHolidays;
206
+ }
207
+ const holidays = index_default({ year, valueAsDate });
208
+ holidaysCache.set(year, holidays);
209
+ return holidays;
210
+ }
211
+
212
+ // src/utils/helpers.ts
213
+ function isSameDate(date1, date2) {
214
+ return date1.getUTCDate() === date2.getUTCDate() && date1.getUTCMonth() === date2.getUTCMonth() && date1.getUTCFullYear() === date2.getUTCFullYear();
215
+ }
216
+
217
+ // src/utils/isHoliday.ts
218
+ function isHoliday(date) {
219
+ const holidays = getHolidaysForYear(date.getUTCFullYear(), {
220
+ valueAsDate: true
221
+ });
222
+ return holidays.some(
223
+ ({ celebrationDate }) => isSameDate(celebrationDate, date)
224
+ );
225
+ }
226
+
227
+ // src/utils/holidaysWithinInterval.ts
228
+ function holidaysWithinInterval({
229
+ start,
230
+ end,
231
+ valueAsDate = false
232
+ }) {
233
+ if (start >= end) {
234
+ throw new Error("end date should be greater than start date");
235
+ }
236
+ const yearEnd = end.getUTCFullYear();
237
+ const yearStart = start.getUTCFullYear();
238
+ const holidays = Array.from(
239
+ { length: yearEnd - yearStart + 1 },
240
+ (_, i) => getHolidaysForYear(i + yearStart, { valueAsDate: true })
241
+ ).flat();
242
+ const holidaysWithin = holidays.filter(
243
+ ({ celebrationDate }) => celebrationDate >= start && celebrationDate <= end
244
+ );
245
+ if (valueAsDate) {
246
+ return holidaysWithin;
247
+ }
248
+ return holidaysWithin.map((holiday) => ({
249
+ ...holiday,
250
+ date: holiday.date.toISOString().slice(0, 10),
251
+ celebrationDate: holiday.celebrationDate.toISOString().slice(0, 10)
252
+ }));
253
+ }
254
+
255
+ // src/index.ts
256
+ var FIRST_HOLIDAY_YEAR = 1583;
257
+ var LAST_HOLIDAY_YEAR = 4099;
258
+ function colombianHolidays({
259
+ year = (/* @__PURE__ */ new Date()).getUTCFullYear(),
260
+ month,
261
+ valueAsDate = false
262
+ } = {}) {
263
+ if (year < FIRST_HOLIDAY_YEAR || year > LAST_HOLIDAY_YEAR) {
264
+ throw new Error(
265
+ `The year should be between ${FIRST_HOLIDAY_YEAR} and ${LAST_HOLIDAY_YEAR}`
266
+ );
267
+ }
268
+ return holidays_default.map((holiday) => helpers_default(holiday, { year, valueAsDate })).filter((holiday) => {
269
+ if (month === void 0) {
270
+ return true;
271
+ }
272
+ if (typeof holiday.celebrationDate === "string") {
273
+ return Number(holiday.celebrationDate.slice(5, 7)) === month;
274
+ }
275
+ return holiday.celebrationDate.getUTCMonth() + 1 === month;
276
+ }).sort((a, b) => {
277
+ if (a.celebrationDate instanceof Date && b.celebrationDate instanceof Date) {
278
+ return a.celebrationDate.getTime() - b.celebrationDate.getTime();
279
+ }
280
+ if (typeof a.celebrationDate === "string" && typeof b.celebrationDate === "string") {
281
+ return a.celebrationDate.localeCompare(b.celebrationDate);
282
+ }
283
+ throw new Error("Invariant violation: this state is not possible.");
284
+ });
285
+ }
286
+ var index_default = colombianHolidays;
287
+ export {
288
+ FIRST_HOLIDAY_YEAR,
289
+ LAST_HOLIDAY_YEAR,
290
+ colombianHolidays,
291
+ index_default as default,
292
+ getHolidaysForYear,
293
+ holidaysWithinInterval,
294
+ isHoliday
295
+ };
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "colombian-holidays",
3
- "version": "5.0.2",
3
+ "version": "5.0.5",
4
4
  "description": "Colombian holidays",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
7
  "format": "prettier --write .",
8
8
  "lint": "eslint . --ext .ts --fix",
9
- "test": "jest --coverage",
10
- "build": "tsc",
11
- "prepublishOnly": "tsc",
12
- "ts-node": "ts-node"
9
+ "test": "vitest run",
10
+ "build": "tsup src/index.ts --dts --format cjs,esm --out-dir dist",
11
+ "build:cjs": "tsup src/index.ts --format cjs --out-dir dist/cjs",
12
+ "build:esm": "tsup src/index.ts --format esm --out-dir dist/esm",
13
+ "build:types": "tsup src/index.ts --dts-only --out-dir dist/types",
14
+ "prepublishOnly": "npm run build"
13
15
  },
14
16
  "license": "MIT",
15
17
  "bugs": {
@@ -25,19 +27,16 @@
25
27
  "Holidays"
26
28
  ],
27
29
  "devDependencies": {
28
- "@types/jest": "^27.4.1",
29
- "@typescript-eslint/eslint-plugin": "^5.21.0",
30
- "@typescript-eslint/parser": "^5.21.0",
31
- "eslint": "^8.14.0",
32
- "jest": "^27.0.1",
33
- "prettier": "^2.6.2",
34
- "timezone-mock": "^1.3.1",
35
- "ts-jest": "^27.1.4",
36
- "ts-node": "^10.9.1",
37
- "typescript": "^4.6.4"
30
+ "@eslint/js": "^9.32.0",
31
+ "eslint": "^9.32.0",
32
+ "prettier": "^3.6.2",
33
+ "tsup": "^8.5.0",
34
+ "typescript": "^5.8.3",
35
+ "typescript-eslint": "^8.38.0",
36
+ "vitest": "^3.2.4"
38
37
  },
39
38
  "dependencies": {
40
- "pascua": "^2.1.5"
39
+ "pascua": "^2.1.8"
41
40
  },
42
41
  "files": [
43
42
  "dist"
package/dist/helpers.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { Holiday, ColombianHoliday, ColombianHolidayWithNativeDate } from "./types";
2
- export declare const NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
3
- declare function getHoliday(holiday: Holiday, options?: {
4
- year?: number;
5
- valueAsDate: false | undefined;
6
- }): ColombianHoliday;
7
- declare function getHoliday(holiday: Holiday, options: {
8
- year?: number;
9
- valueAsDate: true;
10
- }): ColombianHolidayWithNativeDate;
11
- declare function getHoliday(holiday: Holiday, options?: {
12
- year?: number;
13
- valueAsDate?: boolean;
14
- }): ColombianHoliday | ColombianHolidayWithNativeDate;
15
- export default getHoliday;
package/dist/helpers.js DELETED
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NEW_HOLIDAY_SCHEMA_START_YEAR = void 0;
7
- const pascua_1 = __importDefault(require("pascua"));
8
- // 1984 is the year when the current holidays scheme is enforced
9
- // http://www.alcaldiabogota.gov.co/sisjur/normas/Norma1.jsp?i=4954
10
- exports.NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
11
- function getNextDayOfWeek(date, dayOfWeek) {
12
- const resultDate = new Date(date);
13
- resultDate.setUTCDate(date.getUTCDate() + ((7 + dayOfWeek - date.getUTCDay()) % 7));
14
- return resultDate;
15
- }
16
- function getNextMonday(date) {
17
- const MONDAY = 1;
18
- return getNextDayOfWeek(date, MONDAY);
19
- }
20
- function isEasterHoliday(holiday) {
21
- return "offset" in holiday;
22
- }
23
- function getHolidayDate(holiday, year) {
24
- if (isEasterHoliday(holiday)) {
25
- const { month, day } = (0, pascua_1.default)(year);
26
- const date = new Date(generateUtcStringFromDateParts(year, month, 1));
27
- date.setUTCDate(day + holiday.offset);
28
- return date;
29
- }
30
- return new Date(generateUtcStringFromDateParts(year, holiday.month, holiday.day));
31
- }
32
- function generateUtcStringFromDateParts(year, month, day) {
33
- return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
34
- }
35
- function getHoliday(holiday, { year = new Date().getUTCFullYear(), valueAsDate = false, } = {}) {
36
- const holidayDate = getHolidayDate(holiday, year);
37
- const celebrationDate = year >= exports.NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday
38
- ? getNextMonday(holidayDate)
39
- : holidayDate;
40
- return {
41
- date: valueAsDate ? holidayDate : holidayDate.toISOString().slice(0, 10),
42
- celebrationDate: valueAsDate
43
- ? celebrationDate
44
- : celebrationDate.toISOString().slice(0, 10),
45
- name: holiday.name,
46
- nextMonday: year >= exports.NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday,
47
- };
48
- }
49
- exports.default = getHoliday;
50
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAQ5B,gEAAgE;AAChE,mEAAmE;AACtD,QAAA,6BAA6B,GAAG,IAAI,CAAC;AAElD,SAAS,gBAAgB,CAAC,IAAU,EAAE,SAAiB;IACrD,MAAM,UAA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,EAChB,EACE,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,EAClC,WAAW,GAAG,KAAK,MACyB,EAAE;IAEhD,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,eAAe,GACnB,IAAI,IAAI,qCAA6B,IAAI,OAAO,CAAC,UAAU;QACzD,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC;QAC5B,CAAC,CAAC,WAAW,CAAC;IAElB,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QACxE,eAAe,EAAE,WAAW;YAC1B,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,IAAI,IAAI,qCAA6B,IAAI,OAAO,CAAC,UAAU;KACxE,CAAC;AACJ,CAAC;AAED,kBAAe,UAAU,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { DateHoliday, EasterHoliday } from "./types";
2
- declare const _default: (DateHoliday | EasterHoliday)[];
3
- export default _default;
package/dist/holidays.js DELETED
@@ -1,147 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dateHolidays = [
4
- {
5
- month: 1,
6
- day: 1,
7
- name: {
8
- es: "Año Nuevo",
9
- en: "New Year's Day",
10
- },
11
- nextMonday: false,
12
- },
13
- {
14
- month: 1,
15
- day: 6,
16
- name: {
17
- es: "Reyes Magos",
18
- en: "Epiphany",
19
- },
20
- nextMonday: true,
21
- },
22
- {
23
- month: 3,
24
- day: 19,
25
- name: {
26
- es: "San José",
27
- en: "Saint Joseph's Day",
28
- },
29
- nextMonday: true,
30
- },
31
- {
32
- month: 5,
33
- day: 1,
34
- name: {
35
- es: "Día del Trabajo",
36
- en: "Labour Day",
37
- },
38
- nextMonday: false,
39
- },
40
- {
41
- month: 6,
42
- day: 29,
43
- name: {
44
- es: "San Pedro y San Pablo",
45
- en: "Saint Peter and Saint Paul",
46
- },
47
- nextMonday: true,
48
- },
49
- {
50
- month: 7,
51
- day: 20,
52
- name: {
53
- es: "Grito de la Independencia",
54
- en: "Declaration of Independence",
55
- },
56
- nextMonday: false,
57
- },
58
- {
59
- month: 8,
60
- day: 7,
61
- name: {
62
- es: "Batalla de Boyacá",
63
- en: "Battle of Boyacá",
64
- },
65
- nextMonday: false,
66
- },
67
- {
68
- month: 8,
69
- day: 15,
70
- name: {
71
- es: "Asunción de la Virgen",
72
- en: "Assumption of Mary",
73
- },
74
- nextMonday: true,
75
- },
76
- {
77
- month: 10,
78
- day: 12,
79
- name: {
80
- es: "Día de la Raza",
81
- en: "Columbus Day",
82
- },
83
- nextMonday: true,
84
- },
85
- {
86
- month: 11,
87
- day: 1,
88
- name: {
89
- es: "Todos los Santos",
90
- en: "All Saints’ Day",
91
- },
92
- nextMonday: true,
93
- },
94
- {
95
- month: 11,
96
- day: 11,
97
- name: { es: "Independencia de Cartagena", en: "Independence of Cartagena" },
98
- nextMonday: true,
99
- },
100
- {
101
- month: 12,
102
- day: 8,
103
- name: { es: "Inmaculada Concepción", en: "Immaculate Conception" },
104
- nextMonday: false,
105
- },
106
- {
107
- month: 12,
108
- day: 25,
109
- name: { es: "Navidad", en: "Christmas" },
110
- nextMonday: false,
111
- },
112
- ];
113
- // We could simplify the calculation by setting the offset to match Monday.
114
- // For example, the date for the 'Corpus Christi' is 60 days after Easter
115
- // and that's the date it is celebrated in most countries. In Colombia,
116
- // that date is moved to the next monday, hence, we use 60 for the offset
117
- // and then get the next monday instead of directly using 64 as the offset.
118
- // https://www.alcaldiabogota.gov.co/sisjur/normas/Norma1.jsp?i=4954
119
- const easterHolidays = [
120
- {
121
- offset: -3,
122
- name: { es: "Jueves Santo", en: "Maundy Thursday" },
123
- nextMonday: false,
124
- },
125
- {
126
- offset: -2,
127
- name: { es: "Viernes Santo", en: "Good Friday" },
128
- nextMonday: false,
129
- },
130
- {
131
- offset: 39,
132
- name: { es: "Ascensión del Señor", en: "Ascension of Jesus" },
133
- nextMonday: true,
134
- },
135
- {
136
- offset: 60,
137
- name: { es: "Corpus Christi", en: "Corpus Christi" },
138
- nextMonday: true,
139
- },
140
- {
141
- offset: 68,
142
- name: { es: "Sagrado Corazón de Jesús", en: "Sacred Heart" },
143
- nextMonday: true,
144
- },
145
- ];
146
- exports.default = [...dateHolidays, ...easterHolidays];
147
- //# sourceMappingURL=holidays.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"holidays.js","sourceRoot":"","sources":["../src/holidays.ts"],"names":[],"mappings":";;AAEA,MAAM,YAAY,GAAkB;IAClC;QACE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;QACN,IAAI,EAAE;YACJ,EAAE,EAAE,WAAW;YACf,EAAE,EAAE,gBAAgB;SACrB;QACD,UAAU,EAAE,KAAK;KAClB;IACD;QACE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;QACN,IAAI,EAAE;YACJ,EAAE,EAAE,aAAa;YACjB,EAAE,EAAE,UAAU;SACf;QACD,UAAU,EAAE,IAAI;KACjB;IACD;QACE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACJ,EAAE,EAAE,UAAU;YACd,EAAE,EAAE,oBAAoB;SACzB;QACD,UAAU,EAAE,IAAI;KACjB;IACD;QACE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,CAAC;QACN,IAAI,EAAE;YACJ,EAAE,EAAE,iBAAiB;YACrB,EAAE,EAAE,YAAY;SACjB;QACD,UAAU,EAAE,KAAK;KAClB;IACD;QACE,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,EAAE;QACP,IAAI,EAAE;YACJ,EAAE,EAAE,uBAAuB;YAC3B,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AAS,EAAE,EAAE,EAAE,WAAW,EAAE;QACxC,UAAU,EAAE,KAAK;KAClB;CACF,CAAC;AAEF,2EAA2E;AAC3E,yEAAyE;AACzE,uEAAuE;AACvE,yEAAyE;AACzE,2EAA2E;AAC3E,oEAAoE;AACpE,MAAM,cAAc,GAAoB;IACtC;QACE,MAAM,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE,iBAAiB,EAAE;QACnD,UAAU,EAAE,KAAK;KAClB;IACD;QACE,MAAM,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,aAAa,EAAE;QAChD,UAAU,EAAE,KAAK;KAClB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE,oBAAoB,EAAE;QAC7D,UAAU,EAAE,IAAI;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE,gBAAgB,EAAE;QACpD,UAAU,EAAE,IAAI;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE,EAAE,EAAE,0BAA0B,EAAE,EAAE,EAAE,cAAc,EAAE;QAC5D,UAAU,EAAE,IAAI;KACjB;CACF,CAAC;AAEF,kBAAe,CAAC,GAAG,YAAY,EAAE,GAAG,cAAc,CAAC,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAmC;AACnC,0DAAkC;AAGlC,6BAA6B;AAChB,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAC1B,QAAA,iBAAiB,GAAG,IAAI,CAAC;AAoBtC,SAAgB,iBAAiB,CAAC,EAChC,IAAI,GAAG,IAAI,IAAI,EAAE,CAA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7CD,8CA6CC;AAED,kBAAe,iBAAiB,CAAC;AAEjC,+DAA+D;AAAtD,uHAAA,kBAAkB,OAAA;AAC3B,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAClB,yEAAwE;AAA/D,gIAAA,sBAAsB,OAAA"}
package/dist/types.d.ts DELETED
@@ -1,23 +0,0 @@
1
- export interface BasicHoliday {
2
- name: {
3
- en: string;
4
- es: string;
5
- };
6
- nextMonday: boolean;
7
- }
8
- export interface DateHoliday extends BasicHoliday {
9
- month: number;
10
- day: number;
11
- }
12
- export interface EasterHoliday extends BasicHoliday {
13
- offset: number;
14
- }
15
- export interface ColombianHoliday extends BasicHoliday {
16
- date: string;
17
- celebrationDate: string;
18
- }
19
- export interface ColombianHolidayWithNativeDate extends BasicHoliday {
20
- date: Date;
21
- celebrationDate: Date;
22
- }
23
- export type Holiday = DateHoliday | EasterHoliday;
package/dist/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { ColombianHoliday, ColombianHolidayWithNativeDate } from "../types";
2
- export declare function getHoliday(date: Date, options: {
3
- valueAsDate: true;
4
- }): ColombianHolidayWithNativeDate | null;
5
- export declare function getHoliday(date: Date, options?: undefined | {
6
- valueAsDate: false;
7
- }): ColombianHoliday | null;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getHoliday = void 0;
4
- const getHolidaysByYear_1 = require("./getHolidaysByYear");
5
- const helpers_1 = require("./helpers");
6
- function getHoliday(date, options = { valueAsDate: false }) {
7
- const { valueAsDate } = options;
8
- const holiday = (0, getHolidaysByYear_1.getHolidaysForYear)(date.getUTCFullYear(), {
9
- valueAsDate: true,
10
- }).find(({ celebrationDate }) => (0, helpers_1.isSameDate)(celebrationDate, date));
11
- if (!holiday) {
12
- return null;
13
- }
14
- if (valueAsDate) {
15
- return holiday;
16
- }
17
- return {
18
- ...holiday,
19
- date: holiday.date.toISOString().slice(0, 10),
20
- celebrationDate: holiday.celebrationDate.toISOString().slice(0, 10),
21
- };
22
- }
23
- exports.getHoliday = getHoliday;
24
- //# sourceMappingURL=getHoliday.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getHoliday.js","sourceRoot":"","sources":["../../src/utils/getHoliday.ts"],"names":[],"mappings":";;;AACA,2DAAyD;AACzD,uCAAuC;AAUvC,SAAgB,UAAU,CACxB,IAAU,EACV,UAAoC,EAAE,WAAW,EAAE,KAAK,EAAE;IAE1D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,OAAO,GAAG,IAAA,sCAAkB,EAAC,IAAI,CAAC,cAAc,EAAE,EAAE;QACxD,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,IAAA,oBAAU,EAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,IAAI,WAAW,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IACD,OAAO;QACL,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QAC7C,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;KACpE,CAAC;AACJ,CAAC;AApBD,gCAoBC"}
@@ -1,7 +0,0 @@
1
- import type { ColombianHolidayWithNativeDate, ColombianHoliday } from "../types";
2
- export declare function getHolidaysForYear(year: number, options?: {
3
- valueAsDate: false | undefined;
4
- }): ColombianHoliday[];
5
- export declare function getHolidaysForYear(year: number, options?: {
6
- valueAsDate: true;
7
- }): ColombianHolidayWithNativeDate[];