@balmli/homey-public-holidays 0.0.0-stage → 1.2.2
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 +66 -2
- package/dist/countries.d.ts +2 -0
- package/dist/countries.js +221 -0
- package/dist/holidays.d.ts +3 -0
- package/dist/holidays.js +32 -0
- package/dist/holidays_list.d.ts +2 -0
- package/dist/holidays_list.js +3997 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +32 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +9 -0
- package/package.json +51 -4
package/README.md
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Homey Public Holidays
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Utility library that exposes the next few years of public-holiday data for a curated list of countries and regions, tailored for Homey apps but usable in any Node.js project.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Lightweight TypeScript API for checking whether a date is a holiday.
|
|
7
|
+
- Includes helper for day offsets (`yesterday`, `today`, `tomorrow`).
|
|
8
|
+
- Bundles a generated dataset sourced from [`date-holidays`](https://github.com/commenthol/date-holidays).
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @balmli/homey-public-holidays
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import {holidays, Condition, countries} from '@balmli/homey-public-holidays';
|
|
20
|
+
|
|
21
|
+
// Inspect available country/region identifiers
|
|
22
|
+
console.log(countries[0]); // { id: 'AU', name: 'Australia' }
|
|
23
|
+
|
|
24
|
+
// Check if a date is a holiday (returns a Holiday object or false)
|
|
25
|
+
const checkDate = new Date('2027-05-17');
|
|
26
|
+
const result = holidays.isHoliday('NO', checkDate);
|
|
27
|
+
if (result) {
|
|
28
|
+
console.log(result.type, result.name);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Apply relative day offsets
|
|
32
|
+
const yesterday = holidays.calcDate(new Date(), Condition.yesterday);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API Overview
|
|
36
|
+
- `countries`: array of supported `{ id, name }` objects.
|
|
37
|
+
- `holidays.isHoliday(countryId, date, condition?)`: returns the matching holiday entry or `false`.
|
|
38
|
+
- `holidays.calcDate(date, condition?)`: shifts the date by `yesterday` or `tomorrow`, otherwise returns the same day.
|
|
39
|
+
- `Condition`: enum of supported offset keywords.
|
|
40
|
+
|
|
41
|
+
## Regenerating Holiday Data
|
|
42
|
+
The large `lib/holidays_list.ts` file is generated from `date-holidays`. To refresh it with the latest upstream data:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm ci --prefix scripts # skip if dependencies are already installed
|
|
46
|
+
npm run generate
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The generator atomically replaces the generated file with data for the current year and the next two years.
|
|
50
|
+
|
|
51
|
+
## Automated Updates
|
|
52
|
+
|
|
53
|
+
The `Update and publish holidays` GitHub Actions workflow runs on the first day of January, April, July, and October and can also be started manually. It updates `date-holidays`, regenerates the dataset, and, when anything changed:
|
|
54
|
+
|
|
55
|
+
1. Bumps the package's patch version.
|
|
56
|
+
2. Runs the test suite.
|
|
57
|
+
3. Commits the generated data and lockfile changes to `main`.
|
|
58
|
+
4. Publishes the new version to npm (https://www.npmjs.com/package/@balmli/homey-public-holidays) with trusted publishing.
|
|
59
|
+
|
|
60
|
+
The workflow uses the repository's automatically provided `GITHUB_TOKEN`; no npm token secret is required.
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
- `npm run build`: compile the TypeScript sources to `dist/`.
|
|
64
|
+
- `npm test`: build and run the Mocha test suite found in `tests/`.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
ISC © Bjørnar Almli
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countries = void 0;
|
|
4
|
+
exports.countries = [
|
|
5
|
+
{
|
|
6
|
+
"id": "AU",
|
|
7
|
+
"name": "Australia"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "AT",
|
|
11
|
+
"name": "Austria"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": "BE",
|
|
15
|
+
"name": "Belgium"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "BG",
|
|
19
|
+
"name": "Bulgaria"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "CZ",
|
|
23
|
+
"name": "Czech Republic"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "DK",
|
|
27
|
+
"name": "Denmark"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": "EE",
|
|
31
|
+
"name": "Estonia"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "FI",
|
|
35
|
+
"name": "Finland"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "FR",
|
|
39
|
+
"name": "France"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "DE",
|
|
43
|
+
"name": "Germany"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"id": "DE-BB",
|
|
47
|
+
"name": "Germany (Brandenburg)"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "DE-BE",
|
|
51
|
+
"name": "Germany (Berlin)"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"id": "DE-BW",
|
|
55
|
+
"name": "Germany (Baden-Württemberg)"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "DE-BY",
|
|
59
|
+
"name": "Germany (Bayern)"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"id": "DE-BY-A",
|
|
63
|
+
"name": "Germany (Bayern - Stadt Augsburg)"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"id": "DE-BY-EVANG",
|
|
67
|
+
"name": "Germany (Bayern - Überwiegend evangelische Gemeinden)"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": "DE-HB",
|
|
71
|
+
"name": "Germany (Hansestadt Bremen)"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "DE-HE",
|
|
75
|
+
"name": "Germany (Hessen)"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "DE-HH",
|
|
79
|
+
"name": "Germany (Hansestadt Hamburg)"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "DE-MV",
|
|
83
|
+
"name": "Germany (Mecklenburg Vorpommern)"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"id": "DE-NI",
|
|
87
|
+
"name": "Germany (Niedersachsen)"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"id": "DE-NW",
|
|
91
|
+
"name": "Germany (Nordrhein-Westfalen)"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "DE-RP",
|
|
95
|
+
"name": "Germany (Rheinland-Pfalz)"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "DE-SH",
|
|
99
|
+
"name": "Germany (Schleswig-Holstein)"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "DE-SL",
|
|
103
|
+
"name": "Germany (Saarland)"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"id": "DE-SN",
|
|
107
|
+
"name": "Germany (Sachsen)"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"id": "DE-SN-BZ",
|
|
111
|
+
"name": "Germany (Sachsen - Landkreis Bautzen)"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"id": "DE-ST",
|
|
115
|
+
"name": "Germany (Sachsen-Anhalt)"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "DE-TH",
|
|
119
|
+
"name": "Germany (Thüringen)"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "DE-TH-EIC",
|
|
123
|
+
"name": "Germany (Thüringen - Landkreis Eichfeld)"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": "DE-TH-UH",
|
|
127
|
+
"name": "Germany (Thüringen - Unstrut-Hainich-Kreis)"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"id": "DE-TH-WAK",
|
|
131
|
+
"name": "Germany (Thüringen - Wartburgkreis)"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"id": "HU",
|
|
135
|
+
"name": "Hungary"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "IS",
|
|
139
|
+
"name": "Iceland"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"id": "IE",
|
|
143
|
+
"name": "Ireland"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": "IT",
|
|
147
|
+
"name": "Italy"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"id": "LV",
|
|
151
|
+
"name": "Latvia"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": "LI",
|
|
155
|
+
"name": "Lichtenstein"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "LT",
|
|
159
|
+
"name": "Lithuania"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "LU",
|
|
163
|
+
"name": "Luxembourg"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": "NL",
|
|
167
|
+
"name": "Netherlands"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"id": "NO",
|
|
171
|
+
"name": "Norway"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"id": "PL",
|
|
175
|
+
"name": "Poland"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"id": "PT",
|
|
179
|
+
"name": "Portugal"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"id": "RO",
|
|
183
|
+
"name": "Romania"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"id": "RU",
|
|
187
|
+
"name": "Russia"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "SG",
|
|
191
|
+
"name": "Singapore"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"id": "SK",
|
|
195
|
+
"name": "Slovakia"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"id": "SI",
|
|
199
|
+
"name": "Slovenia"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"id": "ES",
|
|
203
|
+
"name": "Spain"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
"id": "SE",
|
|
207
|
+
"name": "Sweden"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"id": "CH",
|
|
211
|
+
"name": "Switzerland"
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
"id": "GB",
|
|
215
|
+
"name": "United Kingdom"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"id": "US",
|
|
219
|
+
"name": "USA"
|
|
220
|
+
}
|
|
221
|
+
];
|
package/dist/holidays.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isHoliday = exports.calcDate = void 0;
|
|
4
|
+
var holidays_list_1 = require("./holidays_list");
|
|
5
|
+
var types_1 = require("./types");
|
|
6
|
+
var addDate = function (date, days) {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
var ret = new Date(date);
|
|
9
|
+
ret.setDate(ret.getDate() + days);
|
|
10
|
+
return ret;
|
|
11
|
+
};
|
|
12
|
+
var calcDate = function (aDate, condition) {
|
|
13
|
+
if (condition === types_1.Condition.yesterday || condition === 'yesterday') {
|
|
14
|
+
return addDate(aDate, -1);
|
|
15
|
+
}
|
|
16
|
+
else if (condition === types_1.Condition.tomorrow || condition === 'tomorrow') {
|
|
17
|
+
return addDate(aDate, 1);
|
|
18
|
+
}
|
|
19
|
+
return aDate;
|
|
20
|
+
};
|
|
21
|
+
exports.calcDate = calcDate;
|
|
22
|
+
var toJSONLocal = function (date) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
var local = new Date(date);
|
|
25
|
+
local.setMinutes(date.getMinutes() - date.getTimezoneOffset());
|
|
26
|
+
return local.toJSON().slice(0, 10);
|
|
27
|
+
};
|
|
28
|
+
var isHoliday = function (country, aDate, condition) {
|
|
29
|
+
var holi = holidays_list_1.holidays_list[country + '-' + toJSONLocal((0, exports.calcDate)(aDate, condition))];
|
|
30
|
+
return !holi ? false : holi;
|
|
31
|
+
};
|
|
32
|
+
exports.isHoliday = isHoliday;
|