colombian-holidays 1.8.0 → 2.0.0

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 CHANGED
@@ -41,30 +41,154 @@ const colombianHolidays2015 = colombianHolidays(2015);
41
41
 
42
42
  The content of the `colombianHolidays2015` variable will be the following array:
43
43
 
44
- <!-- prettier-ignore-start -->
45
44
  ```js
46
45
  [
47
- { date: '2015-01-01', celebrationDate: '2015-01-01', name: 'Año Nuevo', nextMonday: false },
48
- { date: '2015-01-06', celebrationDate: '2015-01-12', name: 'Reyes Magos', nextMonday: true },
49
- { date: '2015-03-19', celebrationDate: '2015-03-23', name: 'San José', nextMonday: true },
50
- { date: '2015-04-02', celebrationDate: '2015-04-02', name: 'Jueves Santo', nextMonday: false },
51
- { date: '2015-04-03', celebrationDate: '2015-04-03', name: 'Viernes Santo', nextMonday: false },
52
- { date: '2015-05-01', celebrationDate: '2015-05-01', name: 'Día del Trabajo', nextMonday: false },
53
- { date: '2015-05-14', celebrationDate: '2015-05-18', name: 'Ascensión del Señor', nextMonday: true },
54
- { date: '2015-06-04', celebrationDate: '2015-06-08', name: 'Corpus Christi', nextMonday: true },
55
- { date: '2015-06-12', celebrationDate: '2015-06-15', name: 'Sagrado Corazón de Jesús', nextMonday: true },
56
- { date: '2015-06-29', celebrationDate: '2015-06-29', name: 'San Pedro y San Pablo', nextMonday: true },
57
- { date: '2015-07-20', celebrationDate: '2015-07-20', name: 'Grito de la Independencia', nextMonday: false },
58
- { date: '2015-08-07', celebrationDate: '2015-08-07', name: 'Batalla de Boyacá', nextMonday: false },
59
- { date: '2015-08-15', celebrationDate: '2015-08-17', name: 'Asunción de la Virgen', nextMonday: true },
60
- { date: '2015-10-12', celebrationDate: '2015-10-12', name: 'Día de la Raza', nextMonday: true },
61
- { date: '2015-11-01', celebrationDate: '2015-11-02', name: 'Todos los Santos', nextMonday: true },
62
- { date: '2015-11-11', celebrationDate: '2015-11-16', name: 'Independencia de Cartagena', nextMonday: true },
63
- { date: '2015-12-08', celebrationDate: '2015-12-08', name: 'Inmaculada Concepción', nextMonday: false },
64
- { date: '2015-12-25', celebrationDate: '2015-12-25', name: 'Navidad', nextMonday: false },
65
- ]
46
+ {
47
+ date: "2015-01-01",
48
+ celebrationDate: "2015-01-01",
49
+ name: {
50
+ es: "Año Nuevo",
51
+ en: "New Year's day",
52
+ },
53
+ nextMonday: false,
54
+ },
55
+ {
56
+ date: "2015-01-06",
57
+ celebrationDate: "2015-01-12",
58
+ name: {
59
+ es: "Reyes Magos",
60
+ en: "Epiphany",
61
+ },
62
+ nextMonday: true,
63
+ },
64
+ {
65
+ date: "2015-03-19",
66
+ celebrationDate: "2015-03-23",
67
+ name: {
68
+ es: "San José",
69
+ en: "Saint Joseph's Day",
70
+ },
71
+ nextMonday: true,
72
+ },
73
+ {
74
+ date: "2015-04-02",
75
+ celebrationDate: "2015-04-02",
76
+ { es: "Jueves Santo", en: "Maundy Thursday" },
77
+ nextMonday: false,
78
+ },
79
+ {
80
+ date: "2015-04-03",
81
+ celebrationDate: "2015-04-03",
82
+ { es: "Viernes Santo", en: "Good Friday" },
83
+ nextMonday: false,
84
+ },
85
+ {
86
+ date: "2015-05-01",
87
+ celebrationDate: "2015-05-01",
88
+ name: {
89
+ es: "Día del Trabajo",
90
+ en: "Labour Day",
91
+ }
92
+ nextMonday: false,
93
+ },
94
+ {
95
+ date: "2015-05-14",
96
+ celebrationDate: "2015-05-18",
97
+ name: { es: "Ascensión del Señor", en: "Ascension of Jesus" },
98
+ nextMonday: true,
99
+ },
100
+ {
101
+ date: "2015-06-04",
102
+ celebrationDate: "2015-06-08",
103
+ name: { es: "Corpus Christi", en: "Corpus Christi" },
104
+ nextMonday: true,
105
+ },
106
+ {
107
+ date: "2015-06-12",
108
+ celebrationDate: "2015-06-15",
109
+ name: { es: "Sagrado Corazón de Jesús", en: "Sacred Heart" },
110
+ nextMonday: true,
111
+ },
112
+ {
113
+ date: "2015-06-29",
114
+ celebrationDate: "2015-06-29",
115
+ name: {
116
+ es: "San Pedro y San Pablo",
117
+ en: "Saint Peter and Saint Paul",
118
+ },
119
+ nextMonday: true,
120
+ },
121
+ {
122
+ date: "2015-07-20",
123
+ celebrationDate: "2015-07-20",
124
+ name: {
125
+ es: "Grito de la Independencia",
126
+ en: "Declaration of Independence",
127
+ },
128
+ nextMonday: false,
129
+ },
130
+ {
131
+ date: "2015-08-07",
132
+ celebrationDate: "2015-08-07",
133
+ name: {
134
+ es: "Batalla de Boyacá",
135
+ en: "Battle of Boyacá",
136
+ },
137
+ nextMonday: false,
138
+ },
139
+ {
140
+ date: "2015-08-15",
141
+ celebrationDate: "2015-08-17",
142
+ name: {
143
+ es: "Asunción de la Virgen",
144
+ en: "Assumption of Mary",
145
+ },
146
+ nextMonday: true,
147
+ },
148
+ {
149
+ date: "2015-10-12",
150
+ celebrationDate: "2015-10-12",
151
+ name: {
152
+ es: "Día de la Raza",
153
+ en: "Columbus Day",
154
+ },
155
+ nextMonday: true,
156
+ },
157
+ {
158
+ date: "2015-11-01",
159
+ celebrationDate: "2015-11-02",
160
+ name: {
161
+ es: "Todos los Santos",
162
+ en: "All Saints’ Day",
163
+ },
164
+ nextMonday: true,
165
+ },
166
+ {
167
+ date: "2015-11-11",
168
+ celebrationDate: "2015-11-16",
169
+ name: { es: "Independencia de Cartagena", en: "Independence of Cartagena" },
170
+ nextMonday: true,
171
+ },
172
+ {
173
+ date: "2015-12-08",
174
+ celebrationDate: "2015-12-08",
175
+ name: { es: "Inmaculada Concepción", en: "Immaculate Conception" },
176
+ nextMonday: false,
177
+ },
178
+ {
179
+ date: "2015-12-25",
180
+ celebrationDate: "2015-12-25",
181
+ name: { es: "Navidad", en: "Christmas" },
182
+ nextMonday: false,
183
+ },
184
+ ];
185
+ ```
186
+
187
+ You can opt-in to have the function return native JavaScript dates instead of strings for the `date` and `celebrationDate` properties by using the `returnNativeDate` option:
188
+
189
+ ```js
190
+ const colombianHolidays2015 = colombianHolidays(2015, { returnNativeDate });
66
191
  ```
67
- <!-- prettier-ignore-end -->
68
192
 
69
193
  If the year is omitted, by default the function will return the holidays for the current year:
70
194
 
@@ -72,17 +196,66 @@ If the year is omitted, by default the function will return the holidays for the
72
196
  const currentYearHolidays = colombianHolidays();
73
197
  ```
74
198
 
75
- ### TypeScript
199
+ ## Utils
76
200
 
77
- The module is written in TypeScript and type definitions files are included.
201
+ The package provides two helper functions which can be imported from `lib/utils`:
202
+
203
+ ### isHoliday
204
+
205
+ Returns true if the given date is a colombian holiday, otherwise returns false.
206
+
207
+ ```js
208
+ import { isHoliday } from "colombian-holidays/lib/utils/isHoliday";
209
+
210
+ const date = new Date("2018-01-01T05:00:00.000Z");
211
+
212
+ if (isHoliday(date)) {
213
+ console.log("it is a colombian holiday");
214
+ } else {
215
+ console.log("it is NOT a colombian holiday");
216
+ }
217
+ ```
218
+
219
+ ### holidaysWithinInterval
220
+
221
+ Returns an with the colombian holidays within two dates:
222
+
223
+ ```js
224
+ import { holidaysWithinInterval } from "colombian-holidays/lib/utils/holidaysWithinInterval";
225
+
226
+ const start = new Date("2021-01-01");
227
+ const end = new Date("2021-01-11");
228
+ const holidays = holidaysWithinInterval({ start, end });
229
+ ```
78
230
 
79
- ## Contributing
231
+ returns:
80
232
 
81
- Contributions, issues and feature requests are welcome!
233
+ ```js
234
+ [
235
+ {
236
+ celebrationDate: "2021-01-01",
237
+ date: "2021-01-01",
238
+ name: {
239
+ es: "Año Nuevo",
240
+ en: "New Year's day",
241
+ },
242
+ nextMonday: false,
243
+ },
244
+ {
245
+ celebrationDate: "2021-01-11",
246
+ date: "2021-01-06",
247
+ name: {
248
+ es: "Reyes Magos",
249
+ en: "Epiphany",
250
+ },
251
+ nextMonday: true,
252
+ },
253
+ ];
254
+ ```
82
255
 
83
- ## Show your support
256
+ ### TypeScript
84
257
 
85
- Give a ⭐️ if you like this project!
258
+ The module is written in TypeScript and type definitions files are included.
86
259
 
87
260
  ## License
88
261
 
@@ -0,0 +1,4 @@
1
+ import type { Holiday, ColombianHoliday } from "./types";
2
+ export declare const NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
3
+ declare function getHoliday(holiday: Holiday, year: number): ColombianHoliday;
4
+ export default getHoliday;
package/lib/helpers.js ADDED
@@ -0,0 +1,50 @@
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.setDate(date.getDate() + ((7 + dayOfWeek - date.getDay()) % 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
+ return new Date(year, month - 1, day + holiday.offset);
27
+ }
28
+ const [month, day] = holiday.date.split("-");
29
+ return new Date(year, Number(month) - 1, Number(day));
30
+ }
31
+ function formatDate(date) {
32
+ const year = date.getFullYear();
33
+ const month = String(date.getMonth() + 1).padStart(2, "0");
34
+ const day = String(date.getDate()).padStart(2, "0");
35
+ return `${year}-${month}-${day}`;
36
+ }
37
+ function getHoliday(holiday, year) {
38
+ const holidayDate = getHolidayDate(holiday, year);
39
+ const celebrationDate = year >= exports.NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday
40
+ ? getNextMonday(holidayDate)
41
+ : holidayDate;
42
+ return {
43
+ date: formatDate(holidayDate),
44
+ celebrationDate: formatDate(celebrationDate),
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAG5B,gEAAgE;AAChE,mEAAmE;AACtD,QAAA,6BAA6B,GAAG,IAAI,CAAC;AAElD,SAAS,gBAAgB,CAAC,IAAU,EAAE,SAAiB;IACrD,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC/B,MAAM,MAAM,GAAG,CAAC,CAAC;IACjB,OAAO,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,OAAO,QAAQ,IAAI,OAAO,CAAC;AAC7B,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB,EAAE,IAAY;IACpD,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE;QAC5B,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAA,gBAAM,EAAC,IAAI,CAAC,CAAC;QACpC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;KACxD;IAED,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;AACnC,CAAC;AAED,SAAS,UAAU,CAAC,OAAgB,EAAE,IAAY;IAChD,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;IAClB,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC;QAC7B,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC;QAC5C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,IAAI,IAAI,qCAA6B,IAAI,OAAO,CAAC,UAAU;KACxE,CAAC;AACJ,CAAC;AAED,kBAAe,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { DateHoliday, EasterHoliday } from "./types";
2
+ declare const _default: (DateHoliday | EasterHoliday)[];
3
+ export default _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const dateHolidays = [
4
+ { date: "01-01", name: "Año Nuevo", nextMonday: false },
5
+ { date: "05-01", name: "Día del Trabajo", nextMonday: false },
6
+ { date: "07-20", name: "Grito de la Independencia", nextMonday: false },
7
+ { date: "08-07", name: "Batalla de Boyacá", nextMonday: false },
8
+ { date: "12-08", name: "Inmaculada Concepción", nextMonday: false },
9
+ { date: "12-25", name: "Navidad", nextMonday: false },
10
+ { date: "01-06", name: "Reyes Magos", nextMonday: true },
11
+ { date: "03-19", name: "San José", nextMonday: true },
12
+ { date: "06-29", name: "San Pedro y San Pablo", nextMonday: true },
13
+ { date: "08-15", name: "Asunción de la Virgen", nextMonday: true },
14
+ { date: "10-12", name: "Día de la Raza", nextMonday: true },
15
+ { date: "11-01", name: "Todos los Santos", nextMonday: true },
16
+ { date: "11-11", name: "Independencia de Cartagena", nextMonday: true },
17
+ ];
18
+ // We could simplify the calculation by setting the offset to match Monday.
19
+ // For example, the date for the 'Corpus Christi' is 60 days after Easter
20
+ // and that's the date it is celebrated in most countries. In Colombia,
21
+ // that date is moved to the next monday, hence, we use 60 for the offset
22
+ // and then get the next monday instead of directly using 64 as the offset.
23
+ // https://www.alcaldiabogota.gov.co/sisjur/normas/Norma1.jsp?i=4954
24
+ const easterHolidays = [
25
+ { offset: -3, name: "Jueves Santo", nextMonday: false },
26
+ { offset: -2, name: "Viernes Santo", nextMonday: false },
27
+ { offset: 39, name: "Ascensión del Señor", nextMonday: true },
28
+ { offset: 60, name: "Corpus Christi", nextMonday: true },
29
+ { offset: 68, name: "Sagrado Corazón de Jesús", nextMonday: true },
30
+ ];
31
+ exports.default = [...dateHolidays, ...easterHolidays];
32
+ //# sourceMappingURL=holidays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holidays.js","sourceRoot":"","sources":["../src/holidays.ts"],"names":[],"mappings":";;AAEA,MAAM,YAAY,GAAkB;IAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE;IACvD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,KAAK,EAAE;IAC7D,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,EAAE,UAAU,EAAE,KAAK,EAAE;IACvE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,KAAK,EAAE;IAC/D,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,UAAU,EAAE,KAAK,EAAE;IACnE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE;IACrD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE;IACxD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE;IACrD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,UAAU,EAAE,IAAI,EAAE;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,UAAU,EAAE,IAAI,EAAE;IAClE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE;IAC3D,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7D,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,UAAU,EAAE,IAAI,EAAE;CACxE,CAAC;AAEF,2EAA2E;AAC3E,yEAAyE;AACzE,uEAAuE;AACvE,yEAAyE;AACzE,2EAA2E;AAC3E,oEAAoE;AACpE,MAAM,cAAc,GAAoB;IACtC,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE;IACvD,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE;IACxD,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,UAAU,EAAE,IAAI,EAAE;IAC7D,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE;IACxD,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,0BAA0B,EAAE,UAAU,EAAE,IAAI,EAAE;CACnE,CAAC;AAEF,kBAAe,CAAC,GAAG,YAAY,EAAE,GAAG,cAAc,CAAC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { ColombianHoliday } from "./types";
2
+ export declare const FIRST_HOLIDAY_YEAR = 1583;
3
+ export declare const LAST_HOLIDAY_YEAR = 4099;
4
+ declare function colombianHolidays(year?: number): ColombianHoliday[];
5
+ export default colombianHolidays;
package/lib/index.js ADDED
@@ -0,0 +1,21 @@
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.LAST_HOLIDAY_YEAR = exports.FIRST_HOLIDAY_YEAR = void 0;
7
+ const helpers_1 = __importDefault(require("./helpers"));
8
+ const holidays_1 = __importDefault(require("./holidays"));
9
+ // pascua package year limits
10
+ exports.FIRST_HOLIDAY_YEAR = 1583;
11
+ exports.LAST_HOLIDAY_YEAR = 4099;
12
+ function colombianHolidays(year = new Date().getFullYear()) {
13
+ if (year < exports.FIRST_HOLIDAY_YEAR || year > exports.LAST_HOLIDAY_YEAR) {
14
+ throw new Error(`The year should be between ${exports.FIRST_HOLIDAY_YEAR} and ${exports.LAST_HOLIDAY_YEAR}`);
15
+ }
16
+ return holidays_1.default
17
+ .map((holiday) => (0, helpers_1.default)(holiday, year))
18
+ .sort((a, b) => a.celebrationDate.localeCompare(b.celebrationDate));
19
+ }
20
+ exports.default = colombianHolidays;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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;AAEtC,SAAS,iBAAiB,CACxB,OAAe,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;IAEvC,IAAI,IAAI,GAAG,0BAAkB,IAAI,IAAI,GAAG,yBAAiB,EAAE;QACzD,MAAM,IAAI,KAAK,CACb,8BAA8B,0BAAkB,QAAQ,yBAAiB,EAAE,CAC5E,CAAC;KACH;IAED,OAAO,kBAAQ;SACZ,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,iBAAU,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;SAC3C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ export interface BasicHoliday {
2
+ name: string;
3
+ nextMonday: boolean;
4
+ }
5
+ export interface DateHoliday extends BasicHoliday {
6
+ date: string;
7
+ }
8
+ export interface EasterHoliday extends BasicHoliday {
9
+ offset: number;
10
+ }
11
+ export interface ColombianHoliday extends BasicHoliday {
12
+ date: string;
13
+ celebrationDate: string;
14
+ }
15
+ export type Holiday = DateHoliday | EasterHoliday;
package/lib/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/lib/utils.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function isHoliday(date: Date): boolean;
package/lib/utils.js ADDED
@@ -0,0 +1,17 @@
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.isHoliday = void 0;
7
+ const _1 = __importDefault(require("."));
8
+ function isHoliday(date) {
9
+ return (0, _1.default)(date.getUTCFullYear()).some(({ celebrationDate }) => {
10
+ const d = new Date(celebrationDate);
11
+ return (d.getUTCDate() === date.getUTCDate() &&
12
+ d.getUTCMonth() === date.getUTCMonth() &&
13
+ d.getUTCFullYear() === date.getUTCFullYear());
14
+ });
15
+ }
16
+ exports.isHoliday = isHoliday;
17
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAkC;AAElC,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAA,UAAiB,EAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAClD,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE;QACtB,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;QACpC,OAAO,CACL,CAAC,CAAC,UAAU,EAAE,KAAK,IAAI,CAAC,UAAU,EAAE;YACpC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE;YACtC,CAAC,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,CAC7C,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAXD,8BAWC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colombian-holidays",
3
- "version": "1.8.0",
3
+ "version": "2.0.0",
4
4
  "description": "Colombian holidays",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {