colombian-holidays 1.7.6 → 1.8.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
@@ -17,9 +17,9 @@ npm install colombian-holidays
17
17
 
18
18
  ## Usage
19
19
 
20
- The module exports a single function that to get all the holidays for a given year, returning an array with the holidays for the requested year.
20
+ The module exports a single function to get all the holidays for a given year, returning an array with the holidays for the requested year.
21
21
 
22
- The `year` should be between 1984 and 4099.
22
+ The `year` should be between 1583 and 4099.
23
23
 
24
24
  ### CommonJS
25
25
 
@@ -35,7 +35,7 @@ import colombianHolidays from "colombian-holidays";
35
35
 
36
36
  You get a function that you can use to get the complete list of holidays for a given year:
37
37
 
38
- ```
38
+ ```js
39
39
  const colombianHolidays2015 = colombianHolidays(2015);
40
40
  ```
41
41
 
@@ -69,7 +69,7 @@ The content of the `colombianHolidays2015` variable will be the following array:
69
69
  If the year is omitted, by default the function will return the holidays for the current year:
70
70
 
71
71
  ```js
72
- const colombianHolidays = colombianHolidays();
72
+ const currentYearHolidays = colombianHolidays();
73
73
  ```
74
74
 
75
75
  ### TypeScript
package/package.json CHANGED
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "colombian-holidays",
3
- "version": "1.7.6",
3
+ "version": "1.8.0",
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",
11
- "postinstall": "git config core.hooksPath .githooks || true",
12
- "prepare": "git config core.hooksPath .githooks || true"
10
+ "build": "tsc"
13
11
  },
14
12
  "license": "MIT",
15
13
  "bugs": {
16
14
  "url": "https://github.com/MauricioRobayo/colombian-holidays/issues"
17
15
  },
18
- "homepage": "https://www.mauriciorobayo.com/colombian-holidays",
16
+ "homepage": "https://github.com/MauricioRobayo/colombian-holidays",
19
17
  "author": "Mauricio Robayo <rfmajo@gmail.com> (https://www.mauriciorobayo.com)",
20
18
  "keywords": [
21
19
  "Colombian holidays",
@@ -25,22 +23,18 @@
25
23
  "Holidays"
26
24
  ],
27
25
  "devDependencies": {
28
- "@commitlint/cli": "^13.1.0",
29
- "@commitlint/config-conventional": "^13.1.0",
30
- "@types/jest": "^27.0.0",
31
- "@typescript-eslint/eslint-plugin": "^4.29.2",
32
- "@typescript-eslint/parser": "^4.29.2",
33
- "eslint": "^7.32.0",
26
+ "@types/jest": "^27.4.1",
27
+ "@typescript-eslint/eslint-plugin": "^5.21.0",
28
+ "@typescript-eslint/parser": "^5.21.0",
29
+ "eslint": "^8.14.0",
34
30
  "jest": "^27.0.1",
35
- "lint-staged": "^11.0.0",
36
- "prettier": "^2.3.0",
37
- "semantic-release": "^17.4.3",
38
- "timezone-mock": "^1.1.4",
39
- "ts-jest": "^27.0.1",
40
- "typescript": "^4.3.2"
31
+ "prettier": "^2.6.2",
32
+ "timezone-mock": "^1.3.1",
33
+ "ts-jest": "^27.1.4",
34
+ "typescript": "^4.6.4"
41
35
  },
42
36
  "dependencies": {
43
- "pascua": "^2.1.1"
37
+ "pascua": "^2.1.5"
44
38
  },
45
39
  "files": [
46
40
  "lib"
@@ -49,20 +43,6 @@
49
43
  "type": "git",
50
44
  "url": "https://github.com/MauricioRobayo/colombian-holidays.git"
51
45
  },
52
- "lint-staged": {
53
- "src/**/*.js": [
54
- "eslint --fix",
55
- "jest --bail --findRelatedTests"
56
- ],
57
- "**/*.{ts,md}": [
58
- "prettier --write"
59
- ]
60
- },
61
- "commitlint": {
62
- "extends": [
63
- "@commitlint/config-conventional"
64
- ]
65
- },
66
46
  "release": {
67
47
  "branches": [
68
48
  "main"
package/lib/helpers.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Holiday, ColombianHoliday } from './types';
2
- declare function getHoliday(holiday: Holiday, year: number): ColombianHoliday;
3
- export default getHoliday;
package/lib/helpers.js DELETED
@@ -1,46 +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
- const pascua_1 = __importDefault(require("pascua"));
7
- function getNextDayOfWeek(date, dayOfWeek) {
8
- const resultDate = new Date(date);
9
- resultDate.setDate(date.getDate() + ((7 + dayOfWeek - date.getDay()) % 7));
10
- return resultDate;
11
- }
12
- function getNextMonday(date) {
13
- const MONDAY = 1;
14
- return getNextDayOfWeek(date, MONDAY);
15
- }
16
- function isEasterHoliday(holiday) {
17
- return 'offset' in holiday;
18
- }
19
- function getHolidayDate(holiday, year) {
20
- if (isEasterHoliday(holiday)) {
21
- const { month, day } = pascua_1.default(year);
22
- return new Date(year, month - 1, day + holiday.offset);
23
- }
24
- const [month, day] = holiday.date.split('-');
25
- return new Date(year, Number(month) - 1, Number(day));
26
- }
27
- function formatDate(date) {
28
- const year = date.getFullYear();
29
- const month = String(date.getMonth() + 1).padStart(2, '0');
30
- const day = String(date.getDate()).padStart(2, '0');
31
- return `${year}-${month}-${day}`;
32
- }
33
- function getHoliday(holiday, year) {
34
- const holidayDate = getHolidayDate(holiday, year);
35
- const celebrationDate = holiday.nextMonday
36
- ? getNextMonday(holidayDate)
37
- : holidayDate;
38
- return {
39
- date: formatDate(holidayDate),
40
- celebrationDate: formatDate(celebrationDate),
41
- name: holiday.name,
42
- nextMonday: holiday.nextMonday,
43
- };
44
- }
45
- exports.default = getHoliday;
46
- //# sourceMappingURL=helpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAG5B,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,GA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AAED,SAAS,UAAU,CAAC,OAAgB,EAAE,IAAY;IAChD,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,OAAO,CAAC,UAAU;QACxC,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC;QAC5B,CAAC,CAAC,WAAW,CAAC;IAEhB,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC;QAC7B,eAAe,EAAE,UAAU,CAAC,eAAe,CAAC;QAC5C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC;AACJ,CAAC;AAED,kBAAe,UAAU,CAAC"}
package/lib/holidays.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { DateHoliday, EasterHoliday } from './types';
2
- declare const _default: (DateHoliday | EasterHoliday)[];
3
- export default _default;
package/lib/holidays.js DELETED
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,5 +0,0 @@
1
- import { ColombianHoliday } from "./types";
2
- export declare const FIRST_HOLIDAY_YEAR = 1984;
3
- export declare const LAST_HOLIDAY_YEAR = 4099;
4
- declare function colombianHolidays(year?: number): ColombianHoliday[];
5
- export default colombianHolidays;
package/lib/index.js DELETED
@@ -1,23 +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.LAST_HOLIDAY_YEAR = exports.FIRST_HOLIDAY_YEAR = void 0;
7
- const helpers_1 = __importDefault(require("./helpers"));
8
- const holidays_1 = __importDefault(require("./holidays"));
9
- // 1984 is the year when the current holidays scheme is enforced
10
- // http://www.alcaldiabogota.gov.co/sisjur/normas/Norma1.jsp?i=4954
11
- exports.FIRST_HOLIDAY_YEAR = 1984;
12
- // The pascua package calculates Easter until 4099.
13
- exports.LAST_HOLIDAY_YEAR = 4099;
14
- function colombianHolidays(year = new Date().getFullYear()) {
15
- if (year < exports.FIRST_HOLIDAY_YEAR || year > exports.LAST_HOLIDAY_YEAR) {
16
- throw new Error(`The year should be between ${exports.FIRST_HOLIDAY_YEAR} and ${exports.LAST_HOLIDAY_YEAR}`);
17
- }
18
- return holidays_1.default
19
- .map((holiday) => helpers_1.default(holiday, year))
20
- .sort((a, b) => a.celebrationDate.localeCompare(b.celebrationDate));
21
- }
22
- exports.default = colombianHolidays;
23
- //# sourceMappingURL=index.js.map
package/lib/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,gEAAgE;AAChE,mEAAmE;AACtD,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAEvC,mDAAmD;AACtC,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,iBAAU,CAAC,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 DELETED
@@ -1,15 +0,0 @@
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 declare type Holiday = DateHoliday | EasterHoliday;
package/lib/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/lib/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}