es-regional-holidays 0.1.0 → 0.1.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/LICENSE.md +21 -0
- package/README.md +137 -1
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +708 -0
- package/dist/index.mjs +676 -0
- package/package.json +39 -17
- package/src/data/boe/boe_holidays_2026_raw.json +0 -452
- package/src/data/boe_holidays_2026_national_regional.json +0 -584
- package/src/index.ts +0 -2
- package/src/types.ts +0 -9
- package/tsconfig.json +0 -15
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Juan Melo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1 +1,137 @@
|
|
|
1
|
-
# es-regional-holidays
|
|
1
|
+
# es-regional-holidays
|
|
2
|
+
|
|
3
|
+
es-regional-holidays is a lightweight, TypeScript-first library that provides official public holidays in Spain by year and autonomous community, based on data published in the Boletín Oficial del Estado (BOE).
|
|
4
|
+
|
|
5
|
+
The library is framework-agnostic and can be used with React, Angular, Vue, or plain Node.js projects.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Official holiday data sourced from the BOE
|
|
10
|
+
- Clear distinction between national and regional holidays
|
|
11
|
+
- Zero runtime dependencies
|
|
12
|
+
- Fully typed with TypeScript
|
|
13
|
+
- Compatible with modern bundlers (ESM and CJS)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
The package is available on npm.
|
|
18
|
+
|
|
19
|
+
Using npm:
|
|
20
|
+
npm install es-regional-holidays
|
|
21
|
+
|
|
22
|
+
Using yarn:
|
|
23
|
+
yarn add es-regional-holidays
|
|
24
|
+
|
|
25
|
+
Using pnpm:
|
|
26
|
+
pnpm add es-regional-holidays
|
|
27
|
+
|
|
28
|
+
## Basic usage
|
|
29
|
+
|
|
30
|
+
### Get all holidays for a region
|
|
31
|
+
|
|
32
|
+
Returns all applicable holidays for a given region and year, including national common holidays and region-managed holidays.
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { getAllHolidaysByRegionCode } from "es-regional-holidays";
|
|
36
|
+
|
|
37
|
+
const holidays = getAllHolidaysByRegionCode("CN", 2026);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Example result:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
[
|
|
44
|
+
{ date: "2026-01-01", name: "Año Nuevo", scope: "national" },
|
|
45
|
+
{ date: "2026-01-06", name: "Epifanía del Señor", scope: "regional", region: "CN" },
|
|
46
|
+
{ date: "2026-05-30", name: "Día de Canarias", scope: "regional", region: "CN" }
|
|
47
|
+
]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Check if a date is a holiday
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { isHoliday } from "es-regional-holidays";
|
|
54
|
+
|
|
55
|
+
isHoliday("2026-05-30", "CN");
|
|
56
|
+
isHoliday("2026-05-30", "MD");
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The function accepts both YYYY-MM-DD strings and Date objects.
|
|
60
|
+
|
|
61
|
+
## National holidays only
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { getNationalHolidays } from "es-regional-holidays";
|
|
65
|
+
|
|
66
|
+
const nationalHolidays = getNationalHolidays(2026);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Regional holidays only
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { getRegionalHolidaysByRegionCode } from "es-regional-holidays";
|
|
73
|
+
|
|
74
|
+
const regionalHolidays = getRegionalHolidaysByRegionCode("MD", 2026);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## List supported regions
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { getRegions } from "es-regional-holidays";
|
|
81
|
+
|
|
82
|
+
const regions = getRegions();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Region codes follow the official BOE abbreviations.
|
|
86
|
+
|
|
87
|
+
## Holiday data model
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
export interface Holiday {
|
|
91
|
+
date: string;
|
|
92
|
+
name: string;
|
|
93
|
+
region?: string;
|
|
94
|
+
regionName?: string;
|
|
95
|
+
scope: "national" | "regional";
|
|
96
|
+
source?: string;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## National vs regional classification
|
|
101
|
+
|
|
102
|
+
Holiday classification follows administrative practice, not just legal origin.
|
|
103
|
+
|
|
104
|
+
In the BOE, holidays are marked as:
|
|
105
|
+
- `*` -> National holiday, not substitutable
|
|
106
|
+
- `**` -> National holiday, substitutable by the autonomous community
|
|
107
|
+
- `***` -> Regional holiday
|
|
108
|
+
|
|
109
|
+
In this library, holidays are classified as:
|
|
110
|
+
- `*` -> national
|
|
111
|
+
- `**` -> regional
|
|
112
|
+
- `***` -> regional
|
|
113
|
+
|
|
114
|
+
Some holidays are national in origin but managed by autonomous communities. To reflect real regional calendars, these holidays are exposed as regional in the API.
|
|
115
|
+
|
|
116
|
+
## Data source
|
|
117
|
+
|
|
118
|
+
All holiday data is extracted from the official BOE resolution published each year.
|
|
119
|
+
For example, BOE-A-2025-21667 for the year 2026.
|
|
120
|
+
|
|
121
|
+
Raw BOE data is preserved internally for traceability and reproducibility.
|
|
122
|
+
|
|
123
|
+
## Supported years
|
|
124
|
+
|
|
125
|
+
- 2026
|
|
126
|
+
|
|
127
|
+
Additional years will be added incrementally.
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT License
|
|
132
|
+
Copyright (c) Juan Melo
|
|
133
|
+
|
|
134
|
+
## Contributing
|
|
135
|
+
|
|
136
|
+
Issues and pull requests are welcome.
|
|
137
|
+
The project aims to remain small, predictable, and dependency-free.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type RegionCode = "AN" | "AR" | "AS" | "CB" | "CE" | "CL" | "CM" | "CN" | "CT" | "EX" | "GA" | "IB" | "MC" | "MD" | "ML" | "NC" | "PV" | "RI" | "VC";
|
|
2
|
+
type HolidayScope = "national" | "regional";
|
|
3
|
+
interface Holiday {
|
|
4
|
+
/** ISO date: YYYY-MM-DD */
|
|
5
|
+
date: string;
|
|
6
|
+
/** Holiday name in Spanish (as in BOE) */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Region code if scoped to a region (e.g. "CN"). */
|
|
9
|
+
region?: RegionCode;
|
|
10
|
+
/** Region name (e.g. "Canarias") */
|
|
11
|
+
regionName?: string;
|
|
12
|
+
/** "national" = common to all regions. "regional" = chosen/managed by the region. */
|
|
13
|
+
scope: HolidayScope;
|
|
14
|
+
/** BOE id (useful for traceability) */
|
|
15
|
+
source?: string;
|
|
16
|
+
}
|
|
17
|
+
interface HolidaysDataset {
|
|
18
|
+
source: string;
|
|
19
|
+
year: number;
|
|
20
|
+
generated_at?: string;
|
|
21
|
+
national: Array<{
|
|
22
|
+
date: string;
|
|
23
|
+
name: string;
|
|
24
|
+
scope: "national";
|
|
25
|
+
}>;
|
|
26
|
+
regions: Record<RegionCode, {
|
|
27
|
+
regionName: string;
|
|
28
|
+
regional: Array<{
|
|
29
|
+
date: string;
|
|
30
|
+
name: string;
|
|
31
|
+
scope: "regional";
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare function getAllHolidays(year?: number): Holiday[];
|
|
37
|
+
declare function getNationalHolidays(year?: number): Holiday[];
|
|
38
|
+
declare function getRegionalHolidaysByRegionCode(region: RegionCode, year?: number): Holiday[];
|
|
39
|
+
declare function getAllHolidaysByRegionCode(region: RegionCode, year?: number): Holiday[];
|
|
40
|
+
declare function isHoliday(date: string | Date, region?: RegionCode, year?: number): boolean;
|
|
41
|
+
declare function getAllRegions(year?: number): RegionCode[];
|
|
42
|
+
|
|
43
|
+
export { type Holiday, type HolidaysDataset, type RegionCode, getAllHolidays, getAllHolidaysByRegionCode, getAllRegions, getNationalHolidays, getRegionalHolidaysByRegionCode, isHoliday };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type RegionCode = "AN" | "AR" | "AS" | "CB" | "CE" | "CL" | "CM" | "CN" | "CT" | "EX" | "GA" | "IB" | "MC" | "MD" | "ML" | "NC" | "PV" | "RI" | "VC";
|
|
2
|
+
type HolidayScope = "national" | "regional";
|
|
3
|
+
interface Holiday {
|
|
4
|
+
/** ISO date: YYYY-MM-DD */
|
|
5
|
+
date: string;
|
|
6
|
+
/** Holiday name in Spanish (as in BOE) */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Region code if scoped to a region (e.g. "CN"). */
|
|
9
|
+
region?: RegionCode;
|
|
10
|
+
/** Region name (e.g. "Canarias") */
|
|
11
|
+
regionName?: string;
|
|
12
|
+
/** "national" = common to all regions. "regional" = chosen/managed by the region. */
|
|
13
|
+
scope: HolidayScope;
|
|
14
|
+
/** BOE id (useful for traceability) */
|
|
15
|
+
source?: string;
|
|
16
|
+
}
|
|
17
|
+
interface HolidaysDataset {
|
|
18
|
+
source: string;
|
|
19
|
+
year: number;
|
|
20
|
+
generated_at?: string;
|
|
21
|
+
national: Array<{
|
|
22
|
+
date: string;
|
|
23
|
+
name: string;
|
|
24
|
+
scope: "national";
|
|
25
|
+
}>;
|
|
26
|
+
regions: Record<RegionCode, {
|
|
27
|
+
regionName: string;
|
|
28
|
+
regional: Array<{
|
|
29
|
+
date: string;
|
|
30
|
+
name: string;
|
|
31
|
+
scope: "regional";
|
|
32
|
+
}>;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare function getAllHolidays(year?: number): Holiday[];
|
|
37
|
+
declare function getNationalHolidays(year?: number): Holiday[];
|
|
38
|
+
declare function getRegionalHolidaysByRegionCode(region: RegionCode, year?: number): Holiday[];
|
|
39
|
+
declare function getAllHolidaysByRegionCode(region: RegionCode, year?: number): Holiday[];
|
|
40
|
+
declare function isHoliday(date: string | Date, region?: RegionCode, year?: number): boolean;
|
|
41
|
+
declare function getAllRegions(year?: number): RegionCode[];
|
|
42
|
+
|
|
43
|
+
export { type Holiday, type HolidaysDataset, type RegionCode, getAllHolidays, getAllHolidaysByRegionCode, getAllRegions, getNationalHolidays, getRegionalHolidaysByRegionCode, isHoliday };
|