colombian-holidays 1.8.1 → 2.0.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.
- package/README.md +158 -33
- package/lib/helpers.d.ts +10 -2
- package/lib/helpers.js +17 -12
- package/lib/helpers.js.map +1 -1
- package/lib/holidays.js +133 -18
- package/lib/holidays.js.map +1 -1
- package/lib/index.d.ts +10 -2
- package/lib/index.js +13 -3
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +10 -2
- package/lib/utils/holidaysWithinInterval.d.ts +16 -0
- package/lib/utils/holidaysWithinInterval.js +23 -0
- package/lib/utils/holidaysWithinInterval.js.map +1 -0
- package/lib/utils/isHoliday.d.ts +1 -0
- package/lib/utils/isHoliday.js +17 -0
- package/lib/utils/isHoliday.js.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
@@ -41,35 +41,151 @@ 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
|
-
{
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
{
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
+
];
|
66
185
|
```
|
67
|
-
<!-- prettier-ignore-end -->
|
68
186
|
|
69
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:
|
70
188
|
|
71
|
-
<!-- prettier-ignore-start -->
|
72
|
-
|
73
189
|
```js
|
74
190
|
const colombianHolidays2015 = colombianHolidays(2015, { returnNativeDate });
|
75
191
|
```
|
@@ -89,14 +205,14 @@ The package provides two helper functions which can be imported from `lib/utils`
|
|
89
205
|
Returns true if the given date is a colombian holiday, otherwise returns false.
|
90
206
|
|
91
207
|
```js
|
92
|
-
import { isHoliday } from
|
208
|
+
import { isHoliday } from "colombian-holidays/lib/utils/isHoliday";
|
93
209
|
|
94
|
-
const date = new Date("2018-01-01T05:00:00.000Z")
|
210
|
+
const date = new Date("2018-01-01T05:00:00.000Z");
|
95
211
|
|
96
212
|
if (isHoliday(date)) {
|
97
|
-
console.log(
|
213
|
+
console.log("it is a colombian holiday");
|
98
214
|
} else {
|
99
|
-
console.log(
|
215
|
+
console.log("it is NOT a colombian holiday");
|
100
216
|
}
|
101
217
|
```
|
102
218
|
|
@@ -105,27 +221,36 @@ if (isHoliday(date)) {
|
|
105
221
|
Returns an with the colombian holidays within two dates:
|
106
222
|
|
107
223
|
```js
|
108
|
-
import { holidaysWithinInterval } from
|
224
|
+
import { holidaysWithinInterval } from "colombian-holidays/lib/utils/holidaysWithinInterval";
|
109
225
|
|
110
226
|
const start = new Date("2021-01-01");
|
111
227
|
const end = new Date("2021-01-11");
|
112
228
|
const holidays = holidaysWithinInterval({ start, end });
|
113
|
-
|
229
|
+
```
|
230
|
+
|
231
|
+
returns:
|
232
|
+
|
233
|
+
```js
|
114
234
|
[
|
115
235
|
{
|
116
236
|
celebrationDate: "2021-01-01",
|
117
237
|
date: "2021-01-01",
|
118
|
-
name:
|
238
|
+
name: {
|
239
|
+
es: "Año Nuevo",
|
240
|
+
en: "New Year's day",
|
241
|
+
},
|
119
242
|
nextMonday: false,
|
120
243
|
},
|
121
244
|
{
|
122
245
|
celebrationDate: "2021-01-11",
|
123
246
|
date: "2021-01-06",
|
124
|
-
name:
|
247
|
+
name: {
|
248
|
+
es: "Reyes Magos",
|
249
|
+
en: "Epiphany",
|
250
|
+
},
|
125
251
|
nextMonday: true,
|
126
252
|
},
|
127
|
-
]
|
128
|
-
*/
|
253
|
+
];
|
129
254
|
```
|
130
255
|
|
131
256
|
### TypeScript
|
package/lib/helpers.d.ts
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
import type { Holiday, ColombianHoliday } from "./types";
|
1
|
+
import type { Holiday, ColombianHoliday, ColombianHolidayWithNativeDate } from "./types";
|
2
2
|
export declare const NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
|
3
|
-
declare function getHoliday(holiday: Holiday, year: number
|
3
|
+
declare function getHoliday(holiday: Holiday, year: number, options?: undefined | {
|
4
|
+
returnNativeDate?: false | undefined;
|
5
|
+
}): ColombianHoliday;
|
6
|
+
declare function getHoliday(holiday: Holiday, year: number, options?: {
|
7
|
+
returnNativeDate: true;
|
8
|
+
}): ColombianHolidayWithNativeDate;
|
9
|
+
declare function getHoliday(holiday: Holiday, year: number, options?: {
|
10
|
+
returnNativeDate?: boolean;
|
11
|
+
}): ColombianHoliday | ColombianHolidayWithNativeDate;
|
4
12
|
export default getHoliday;
|
package/lib/helpers.js
CHANGED
@@ -10,7 +10,7 @@ const pascua_1 = __importDefault(require("pascua"));
|
|
10
10
|
exports.NEW_HOLIDAY_SCHEMA_START_YEAR = 1984;
|
11
11
|
function getNextDayOfWeek(date, dayOfWeek) {
|
12
12
|
const resultDate = new Date(date);
|
13
|
-
resultDate.
|
13
|
+
resultDate.setUTCDate(date.getUTCDate() + ((7 + dayOfWeek - date.getUTCDay()) % 7));
|
14
14
|
return resultDate;
|
15
15
|
}
|
16
16
|
function getNextMonday(date) {
|
@@ -23,25 +23,30 @@ function isEasterHoliday(holiday) {
|
|
23
23
|
function getHolidayDate(holiday, year) {
|
24
24
|
if (isEasterHoliday(holiday)) {
|
25
25
|
const { month, day } = (0, pascua_1.default)(year);
|
26
|
-
|
26
|
+
const date = new Date(generateUtcStringFromDateParts(year, month, 1));
|
27
|
+
date.setUTCDate(day + holiday.offset);
|
28
|
+
return date;
|
27
29
|
}
|
28
|
-
|
29
|
-
return new Date(year, Number(month) - 1, Number(day));
|
30
|
+
return new Date(generateUtcStringFromDateParts(year, holiday.month, holiday.day));
|
30
31
|
}
|
31
|
-
function
|
32
|
-
|
33
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
34
|
-
const day = String(date.getDate()).padStart(2, "0");
|
35
|
-
return `${year}-${month}-${day}`;
|
32
|
+
function generateUtcStringFromDateParts(year, month, day) {
|
33
|
+
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
36
34
|
}
|
37
|
-
function
|
35
|
+
function generateUtcStringFromDate(date) {
|
36
|
+
return generateUtcStringFromDateParts(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate());
|
37
|
+
}
|
38
|
+
function getHoliday(holiday, year, { returnNativeDate = false } = {}) {
|
38
39
|
const holidayDate = getHolidayDate(holiday, year);
|
39
40
|
const celebrationDate = year >= exports.NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday
|
40
41
|
? getNextMonday(holidayDate)
|
41
42
|
: holidayDate;
|
42
43
|
return {
|
43
|
-
date:
|
44
|
-
|
44
|
+
date: returnNativeDate
|
45
|
+
? holidayDate
|
46
|
+
: generateUtcStringFromDate(holidayDate),
|
47
|
+
celebrationDate: returnNativeDate
|
48
|
+
? celebrationDate
|
49
|
+
: generateUtcStringFromDate(celebrationDate),
|
45
50
|
name: holiday.name,
|
46
51
|
nextMonday: year >= exports.NEW_HOLIDAY_SCHEMA_START_YEAR && holiday.nextMonday,
|
47
52
|
};
|
package/lib/helpers.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;
|
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,UAAU,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,UAAU,CAAC,UAAU,CACnB,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,CAC7D,CAAC;IACF,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,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,8BAA8B,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,IAAI,IAAI,CACb,8BAA8B,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CA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|
-
{
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
{
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
+
},
|
17
112
|
];
|
18
113
|
// We could simplify the calculation by setting the offset to match Monday.
|
19
114
|
// For example, the date for the 'Corpus Christi' is 60 days after Easter
|
@@ -22,11 +117,31 @@ const dateHolidays = [
|
|
22
117
|
// and then get the next monday instead of directly using 64 as the offset.
|
23
118
|
// https://www.alcaldiabogota.gov.co/sisjur/normas/Norma1.jsp?i=4954
|
24
119
|
const easterHolidays = [
|
25
|
-
{
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
+
},
|
30
145
|
];
|
31
146
|
exports.default = [...dateHolidays, ...easterHolidays];
|
32
147
|
//# sourceMappingURL=holidays.js.map
|
package/lib/holidays.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"holidays.js","sourceRoot":"","sources":["../src/holidays.ts"],"names":[],"mappings":";;AAEA,MAAM,YAAY,GAAkB;IAClC,EAAE,
|
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,EA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|
+
import { ColombianHoliday, ColombianHolidayWithNativeDate } from "./types";
|
2
2
|
export declare const FIRST_HOLIDAY_YEAR = 1583;
|
3
3
|
export declare const LAST_HOLIDAY_YEAR = 4099;
|
4
|
-
declare function colombianHolidays(year?: number
|
4
|
+
declare function colombianHolidays(year?: number, options?: undefined | {
|
5
|
+
returnNativeDate?: false | undefined;
|
6
|
+
}): ColombianHoliday[];
|
7
|
+
declare function colombianHolidays(year?: number, options?: {
|
8
|
+
returnNativeDate?: true;
|
9
|
+
}): ColombianHolidayWithNativeDate[];
|
10
|
+
declare function colombianHolidays(year?: number, options?: {
|
11
|
+
returnNativeDate?: boolean;
|
12
|
+
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
5
13
|
export default colombianHolidays;
|
package/lib/index.js
CHANGED
@@ -9,13 +9,23 @@ const holidays_1 = __importDefault(require("./holidays"));
|
|
9
9
|
// pascua package year limits
|
10
10
|
exports.FIRST_HOLIDAY_YEAR = 1583;
|
11
11
|
exports.LAST_HOLIDAY_YEAR = 4099;
|
12
|
-
function colombianHolidays(year = new Date().getFullYear()) {
|
12
|
+
function colombianHolidays(year = new Date().getFullYear(), { returnNativeDate = false } = {}) {
|
13
13
|
if (year < exports.FIRST_HOLIDAY_YEAR || year > exports.LAST_HOLIDAY_YEAR) {
|
14
14
|
throw new Error(`The year should be between ${exports.FIRST_HOLIDAY_YEAR} and ${exports.LAST_HOLIDAY_YEAR}`);
|
15
15
|
}
|
16
16
|
return holidays_1.default
|
17
|
-
.map((holiday) => (0, helpers_1.default)(holiday, year))
|
18
|
-
.sort((a, b) =>
|
17
|
+
.map((holiday) => (0, helpers_1.default)(holiday, year, { returnNativeDate }))
|
18
|
+
.sort((a, b) => {
|
19
|
+
if (a.celebrationDate instanceof Date &&
|
20
|
+
b.celebrationDate instanceof Date) {
|
21
|
+
return a.celebrationDate.getTime() - b.celebrationDate.getTime();
|
22
|
+
}
|
23
|
+
if (typeof a.celebrationDate === "string" &&
|
24
|
+
typeof b.celebrationDate === "string") {
|
25
|
+
return a.celebrationDate.localeCompare(b.celebrationDate);
|
26
|
+
}
|
27
|
+
throw new Error("Invariant violation: this state is not possible.");
|
28
|
+
});
|
19
29
|
}
|
20
30
|
exports.default = colombianHolidays;
|
21
31
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
@@ -1 +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;
|
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;AActC,SAAS,iBAAiB,CACxB,OAAe,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EACvC,EAAE,gBAAgB,GAAG,KAAK,KAAqC,EAAE;IAEjE,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,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACb,IACE,CAAC,CAAC,eAAe,YAAY,IAAI;YACjC,CAAC,CAAC,eAAe,YAAY,IAAI,EACjC;YACA,OAAO,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;SAClE;QAED,IACE,OAAO,CAAC,CAAC,eAAe,KAAK,QAAQ;YACrC,OAAO,CAAC,CAAC,eAAe,KAAK,QAAQ,EACrC;YACA,OAAO,CAAC,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;SAC3D;QAED,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACP,CAAC;AAED,kBAAe,iBAAiB,CAAC"}
|
package/lib/types.d.ts
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
export interface BasicHoliday {
|
2
|
-
name:
|
2
|
+
name: {
|
3
|
+
en: string;
|
4
|
+
es: string;
|
5
|
+
};
|
3
6
|
nextMonday: boolean;
|
4
7
|
}
|
5
8
|
export interface DateHoliday extends BasicHoliday {
|
6
|
-
|
9
|
+
month: number;
|
10
|
+
day: number;
|
7
11
|
}
|
8
12
|
export interface EasterHoliday extends BasicHoliday {
|
9
13
|
offset: number;
|
@@ -12,4 +16,8 @@ export interface ColombianHoliday extends BasicHoliday {
|
|
12
16
|
date: string;
|
13
17
|
celebrationDate: string;
|
14
18
|
}
|
19
|
+
export interface ColombianHolidayWithNativeDate extends BasicHoliday {
|
20
|
+
date: Date;
|
21
|
+
celebrationDate: Date;
|
22
|
+
}
|
15
23
|
export type Holiday = DateHoliday | EasterHoliday;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { ColombianHoliday, ColombianHolidayWithNativeDate } from "../types";
|
2
|
+
export declare function holidaysWithinInterval(options: {
|
3
|
+
start: Date;
|
4
|
+
end: Date;
|
5
|
+
returnNativeDate?: false;
|
6
|
+
}): ColombianHoliday[];
|
7
|
+
export declare function holidaysWithinInterval(options: {
|
8
|
+
start: Date;
|
9
|
+
end: Date;
|
10
|
+
returnNativeDate?: true;
|
11
|
+
}): ColombianHolidayWithNativeDate[];
|
12
|
+
export declare function holidaysWithinInterval(options: {
|
13
|
+
start: Date;
|
14
|
+
end: Date;
|
15
|
+
returnNativeDate?: boolean;
|
16
|
+
}): ColombianHoliday[] | ColombianHolidayWithNativeDate[];
|
@@ -0,0 +1,23 @@
|
|
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.holidaysWithinInterval = void 0;
|
7
|
+
const __1 = __importDefault(require(".."));
|
8
|
+
function holidaysWithinInterval({ start, end, returnNativeDate = false, }) {
|
9
|
+
if (start >= end) {
|
10
|
+
throw new Error("end date should be greater than start date");
|
11
|
+
}
|
12
|
+
const yearEnd = end.getUTCFullYear();
|
13
|
+
const yearStart = start.getUTCFullYear();
|
14
|
+
const holidays = Array.from({ length: yearEnd - yearStart + 1 }, (_, i) => (0, __1.default)(i + yearStart, { returnNativeDate })).flat();
|
15
|
+
return holidays.filter(({ celebrationDate }) => {
|
16
|
+
const date = typeof celebrationDate === "string"
|
17
|
+
? new Date(celebrationDate)
|
18
|
+
: celebrationDate;
|
19
|
+
return date >= start && date <= end;
|
20
|
+
});
|
21
|
+
}
|
22
|
+
exports.holidaysWithinInterval = holidaysWithinInterval;
|
23
|
+
//# sourceMappingURL=holidaysWithinInterval.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"holidaysWithinInterval.js","sourceRoot":"","sources":["../../src/utils/holidaysWithinInterval.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAmC;AAkBnC,SAAgB,sBAAsB,CAAC,EACrC,KAAK,EACL,GAAG,EACH,gBAAgB,GAAG,KAAK,GAKzB;IACC,IAAI,KAAK,IAAI,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;KAC/D;IACD,MAAM,OAAO,GAAG,GAAG,CAAC,cAAc,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;IAEzC,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACxE,IAAA,WAAiB,EAAC,CAAC,GAAG,SAAS,EAAE,EAAE,gBAAgB,EAAE,CAAC,CACvD,CAAC,IAAI,EAAE,CAAC;IAET,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE;QAC7C,MAAM,IAAI,GACR,OAAO,eAAe,KAAK,QAAQ;YACjC,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC;YAC3B,CAAC,CAAC,eAAe,CAAC;QACtB,OAAO,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,wDA0BC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function isHoliday(date: Date): boolean;
|
@@ -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=isHoliday.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"isHoliday.js","sourceRoot":"","sources":["../../src/utils/isHoliday.ts"],"names":[],"mappings":";;;;;;AAAA,2CAAmC;AAEnC,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAA,WAAiB,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,13 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "colombian-holidays",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.1",
|
4
4
|
"description": "Colombian holidays",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"scripts": {
|
7
7
|
"format": "prettier --write .",
|
8
8
|
"lint": "eslint . --ext .ts --fix",
|
9
9
|
"test": "jest --coverage",
|
10
|
-
"build": "tsc"
|
10
|
+
"build": "tsc",
|
11
|
+
"prepublish": "build"
|
11
12
|
},
|
12
13
|
"license": "MIT",
|
13
14
|
"bugs": {
|