ts-time-utils 4.1.0 → 4.4.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 +81 -31
- package/dist/{age.js → age.cjs} +14 -6
- package/dist/{calculate.js → calculate.cjs} +30 -18
- package/dist/{calendar.js → calendar.cjs} +80 -39
- package/dist/{calendars.js → calendars.cjs} +48 -23
- package/dist/{chain.js → chain.cjs} +41 -40
- package/dist/{compare.js → compare.cjs} +58 -28
- package/dist/constants.cjs +19 -0
- package/dist/{countdown.js → countdown.cjs} +16 -7
- package/dist/{cron.js → cron.cjs} +20 -9
- package/dist/{dateRange.js → dateRange.cjs} +42 -26
- package/dist/{duration.js → duration.cjs} +56 -44
- package/dist/esm/chain.js +0 -5
- package/dist/esm/naturalLanguage.d.ts +1 -3
- package/dist/esm/naturalLanguage.d.ts.map +1 -1
- package/dist/esm/naturalLanguage.js +9 -2
- package/dist/esm/plugins.d.ts +0 -6
- package/dist/esm/plugins.d.ts.map +1 -1
- package/dist/esm/plugins.js +36 -42
- package/dist/esm/recurrence.d.ts.map +1 -1
- package/dist/esm/recurrence.js +3 -5
- package/dist/esm/timezone.d.ts +6 -1
- package/dist/esm/timezone.d.ts.map +1 -1
- package/dist/esm/timezone.js +106 -66
- package/dist/esm/types.d.ts +0 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/{finance.js → finance.cjs} +39 -22
- package/dist/{fiscal.js → fiscal.cjs} +36 -17
- package/dist/{format.js → format.cjs} +83 -70
- package/dist/{healthcare.js → healthcare.cjs} +37 -22
- package/dist/{holidays.js → holidays.cjs} +52 -25
- package/dist/index.cjs +595 -0
- package/dist/{interval.js → interval.cjs} +24 -11
- package/dist/{iterate.js → iterate.cjs} +84 -41
- package/dist/{locale.js → locale.cjs} +54 -26
- package/dist/{naturalLanguage.js → naturalLanguage.cjs} +36 -23
- package/dist/naturalLanguage.d.ts +1 -3
- package/dist/naturalLanguage.d.ts.map +1 -1
- package/dist/{parse.js → parse.cjs} +24 -11
- package/dist/{performance.js → performance.cjs} +23 -10
- package/dist/{plugins.js → plugins.cjs} +48 -47
- package/dist/plugins.d.ts +0 -6
- package/dist/plugins.d.ts.map +1 -1
- package/dist/{precision.js → precision.cjs} +74 -37
- package/dist/{rangePresets.js → rangePresets.cjs} +40 -19
- package/dist/{recurrence.js → recurrence.cjs} +27 -21
- package/dist/recurrence.d.ts.map +1 -1
- package/dist/{scheduling.js → scheduling.cjs} +46 -31
- package/dist/{serialize.js → serialize.cjs} +36 -17
- package/dist/{temporal.js → temporal.cjs} +28 -13
- package/dist/{timezone.js → timezone.cjs} +140 -82
- package/dist/timezone.d.ts +6 -1
- package/dist/timezone.d.ts.map +1 -1
- package/dist/{types.js → types.cjs} +9 -3
- package/dist/types.d.ts +0 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/{validate.js → validate.cjs} +54 -26
- package/dist/{workingHours.js → workingHours.cjs} +36 -17
- package/package.json +40 -37
- package/dist/constants.js +0 -16
- package/dist/index.js +0 -72
|
@@ -1,15 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Healthcare utilities for medical scheduling and compliance timing
|
|
3
4
|
* Provides medication schedules, shift patterns, on-call rotations, and compliance windows
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DEFAULT_MEDICATION_CONFIG = exports.SHIFT_DURATIONS = exports.MEDICATION_FREQUENCIES = void 0;
|
|
8
|
+
exports.getMedicationTimes = getMedicationTimes;
|
|
9
|
+
exports.getNextMedicationTime = getNextMedicationTime;
|
|
10
|
+
exports.parseMedicationFrequency = parseMedicationFrequency;
|
|
11
|
+
exports.generateShiftSchedule = generateShiftSchedule;
|
|
12
|
+
exports.getShiftForTime = getShiftForTime;
|
|
13
|
+
exports.isOnShift = isOnShift;
|
|
14
|
+
exports.createOnCallRotation = createOnCallRotation;
|
|
15
|
+
exports.getOnCallStaff = getOnCallStaff;
|
|
16
|
+
exports.isWithinComplianceWindow = isWithinComplianceWindow;
|
|
17
|
+
exports.getComplianceDeadline = getComplianceDeadline;
|
|
18
|
+
exports.timeUntilDeadline = timeUntilDeadline;
|
|
19
|
+
exports.calculateRestBetweenShifts = calculateRestBetweenShifts;
|
|
20
|
+
const duration_js_1 = require("./duration.cjs");
|
|
6
21
|
// ============================================================================
|
|
7
22
|
// Constants
|
|
8
23
|
// ============================================================================
|
|
9
24
|
/**
|
|
10
25
|
* Number of doses per day for each frequency
|
|
11
26
|
*/
|
|
12
|
-
|
|
27
|
+
exports.MEDICATION_FREQUENCIES = {
|
|
13
28
|
'QD': 1,
|
|
14
29
|
'BID': 2,
|
|
15
30
|
'TID': 3,
|
|
@@ -23,7 +38,7 @@ export const MEDICATION_FREQUENCIES = {
|
|
|
23
38
|
/**
|
|
24
39
|
* Hours per shift pattern
|
|
25
40
|
*/
|
|
26
|
-
|
|
41
|
+
exports.SHIFT_DURATIONS = {
|
|
27
42
|
'8hr': 8,
|
|
28
43
|
'12hr': 12,
|
|
29
44
|
'24hr': 24
|
|
@@ -31,7 +46,7 @@ export const SHIFT_DURATIONS = {
|
|
|
31
46
|
/**
|
|
32
47
|
* Default medication timing config
|
|
33
48
|
*/
|
|
34
|
-
|
|
49
|
+
exports.DEFAULT_MEDICATION_CONFIG = {
|
|
35
50
|
wakeTime: '07:00',
|
|
36
51
|
sleepTime: '22:00',
|
|
37
52
|
withMeals: false
|
|
@@ -76,10 +91,10 @@ function setTimeOnDate(date, hour, minute) {
|
|
|
76
91
|
* // Returns [6:00 AM, 1:30 PM, 9:00 PM] (three times daily)
|
|
77
92
|
* ```
|
|
78
93
|
*/
|
|
79
|
-
|
|
94
|
+
function getMedicationTimes(date, frequency, config) {
|
|
80
95
|
const d = toDate(date);
|
|
81
|
-
const cfg = { ...DEFAULT_MEDICATION_CONFIG, ...config };
|
|
82
|
-
const doses = MEDICATION_FREQUENCIES[frequency];
|
|
96
|
+
const cfg = { ...exports.DEFAULT_MEDICATION_CONFIG, ...config };
|
|
97
|
+
const doses = exports.MEDICATION_FREQUENCIES[frequency];
|
|
83
98
|
if (doses === null) {
|
|
84
99
|
return []; // PRN - as needed
|
|
85
100
|
}
|
|
@@ -125,7 +140,7 @@ export function getMedicationTimes(date, frequency, config) {
|
|
|
125
140
|
* // Returns 7:00 PM on same day (next BID dose after 10 AM)
|
|
126
141
|
* ```
|
|
127
142
|
*/
|
|
128
|
-
|
|
143
|
+
function getNextMedicationTime(after, frequency, config) {
|
|
129
144
|
if (frequency === 'PRN') {
|
|
130
145
|
return null;
|
|
131
146
|
}
|
|
@@ -156,7 +171,7 @@ export function getNextMedicationTime(after, frequency, config) {
|
|
|
156
171
|
* parseMedicationFrequency('invalid'); // null
|
|
157
172
|
* ```
|
|
158
173
|
*/
|
|
159
|
-
|
|
174
|
+
function parseMedicationFrequency(freq) {
|
|
160
175
|
const normalized = freq.toLowerCase();
|
|
161
176
|
const mapping = {
|
|
162
177
|
'qd': 'QD',
|
|
@@ -202,10 +217,10 @@ export function parseMedicationFrequency(freq) {
|
|
|
202
217
|
* // Returns 4 shifts: day/night on 15th, day/night on 16th
|
|
203
218
|
* ```
|
|
204
219
|
*/
|
|
205
|
-
|
|
220
|
+
function generateShiftSchedule(start, end, config) {
|
|
206
221
|
const startDate = toDate(start);
|
|
207
222
|
const endDate = toDate(end);
|
|
208
|
-
const shiftHours = SHIFT_DURATIONS[config.pattern];
|
|
223
|
+
const shiftHours = exports.SHIFT_DURATIONS[config.pattern];
|
|
209
224
|
const shiftsPerDay = 24 / shiftHours;
|
|
210
225
|
const shifts = [];
|
|
211
226
|
const current = new Date(startDate.getTime());
|
|
@@ -241,9 +256,9 @@ export function generateShiftSchedule(start, end, config) {
|
|
|
241
256
|
* // Returns { start: 7:00 AM, end: 3:00 PM } (day shift)
|
|
242
257
|
* ```
|
|
243
258
|
*/
|
|
244
|
-
|
|
259
|
+
function getShiftForTime(date, config) {
|
|
245
260
|
const d = toDate(date);
|
|
246
|
-
const shiftHours = SHIFT_DURATIONS[config.pattern];
|
|
261
|
+
const shiftHours = exports.SHIFT_DURATIONS[config.pattern];
|
|
247
262
|
const shiftMs = shiftHours * 60 * 60 * 1000;
|
|
248
263
|
// Find the shift start that contains this time
|
|
249
264
|
const dayStart = new Date(d.getTime());
|
|
@@ -277,10 +292,10 @@ export function getShiftForTime(date, config) {
|
|
|
277
292
|
* ); // true (10 AM is during 7 AM - 3 PM shift)
|
|
278
293
|
* ```
|
|
279
294
|
*/
|
|
280
|
-
|
|
295
|
+
function isOnShift(date, shiftStart, config) {
|
|
281
296
|
const d = toDate(date);
|
|
282
297
|
const start = toDate(shiftStart);
|
|
283
|
-
const shiftHours = SHIFT_DURATIONS[config.pattern];
|
|
298
|
+
const shiftHours = exports.SHIFT_DURATIONS[config.pattern];
|
|
284
299
|
const shiftEnd = new Date(start.getTime() + shiftHours * 60 * 60 * 1000);
|
|
285
300
|
return d.getTime() >= start.getTime() && d.getTime() < shiftEnd.getTime();
|
|
286
301
|
}
|
|
@@ -307,7 +322,7 @@ export function isOnShift(date, shiftStart, config) {
|
|
|
307
322
|
* // Returns 3 slots, one per doctor per day
|
|
308
323
|
* ```
|
|
309
324
|
*/
|
|
310
|
-
|
|
325
|
+
function createOnCallRotation(start, end, staff, hoursPerShift = 24) {
|
|
311
326
|
if (staff.length === 0) {
|
|
312
327
|
return [];
|
|
313
328
|
}
|
|
@@ -343,7 +358,7 @@ export function createOnCallRotation(start, end, staff, hoursPerShift = 24) {
|
|
|
343
358
|
* // Returns 'Dr. Jones' (whoever is on call at 3 AM on the 16th)
|
|
344
359
|
* ```
|
|
345
360
|
*/
|
|
346
|
-
|
|
361
|
+
function getOnCallStaff(date, rotation) {
|
|
347
362
|
const d = toDate(date);
|
|
348
363
|
for (const slot of rotation) {
|
|
349
364
|
if (d.getTime() >= slot.start.getTime() && d.getTime() < slot.end.getTime()) {
|
|
@@ -370,7 +385,7 @@ export function getOnCallStaff(date, rotation) {
|
|
|
370
385
|
* ); // true (event occurred before deadline)
|
|
371
386
|
* ```
|
|
372
387
|
*/
|
|
373
|
-
|
|
388
|
+
function isWithinComplianceWindow(event, deadline) {
|
|
374
389
|
const eventDate = toDate(event);
|
|
375
390
|
const deadlineDate = toDate(deadline);
|
|
376
391
|
return eventDate.getTime() <= deadlineDate.getTime();
|
|
@@ -391,7 +406,7 @@ export function isWithinComplianceWindow(event, deadline) {
|
|
|
391
406
|
* // Returns 2024-01-18T08:00:00 (72 hours later)
|
|
392
407
|
* ```
|
|
393
408
|
*/
|
|
394
|
-
|
|
409
|
+
function getComplianceDeadline(event, windowHours) {
|
|
395
410
|
const eventDate = toDate(event);
|
|
396
411
|
return new Date(eventDate.getTime() + windowHours * 60 * 60 * 1000);
|
|
397
412
|
}
|
|
@@ -411,14 +426,14 @@ export function getComplianceDeadline(event, windowHours) {
|
|
|
411
426
|
* // Returns Duration of 24 hours
|
|
412
427
|
* ```
|
|
413
428
|
*/
|
|
414
|
-
|
|
429
|
+
function timeUntilDeadline(event, deadline) {
|
|
415
430
|
const eventDate = toDate(event);
|
|
416
431
|
const deadlineDate = toDate(deadline);
|
|
417
432
|
const diff = deadlineDate.getTime() - eventDate.getTime();
|
|
418
433
|
if (diff < 0) {
|
|
419
434
|
return null; // Already past deadline
|
|
420
435
|
}
|
|
421
|
-
return Duration.fromMilliseconds(diff);
|
|
436
|
+
return duration_js_1.Duration.fromMilliseconds(diff);
|
|
422
437
|
}
|
|
423
438
|
// ============================================================================
|
|
424
439
|
// Utility Functions
|
|
@@ -439,7 +454,7 @@ export function timeUntilDeadline(event, deadline) {
|
|
|
439
454
|
* // Returns 12 (hours of rest)
|
|
440
455
|
* ```
|
|
441
456
|
*/
|
|
442
|
-
|
|
457
|
+
function calculateRestBetweenShifts(shift1End, shift2Start) {
|
|
443
458
|
const end = toDate(shift1End);
|
|
444
459
|
const start = toDate(shift2Start);
|
|
445
460
|
const diffMs = start.getTime() - end.getTime();
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview International holiday utilities
|
|
3
4
|
* Calculate holidays for multiple countries including fixed, movable, and lunar-based holidays
|
|
4
5
|
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getUKHolidays = getUKHolidays;
|
|
8
|
+
exports.getNetherlandsHolidays = getNetherlandsHolidays;
|
|
9
|
+
exports.getGermanyHolidays = getGermanyHolidays;
|
|
10
|
+
exports.getCanadaHolidays = getCanadaHolidays;
|
|
11
|
+
exports.getAustraliaHolidays = getAustraliaHolidays;
|
|
12
|
+
exports.getItalyHolidays = getItalyHolidays;
|
|
13
|
+
exports.getSpainHolidays = getSpainHolidays;
|
|
14
|
+
exports.getChinaHolidays = getChinaHolidays;
|
|
15
|
+
exports.getIndiaHolidays = getIndiaHolidays;
|
|
16
|
+
exports.getJapanHolidays = getJapanHolidays;
|
|
17
|
+
exports.getFranceHolidays = getFranceHolidays;
|
|
18
|
+
exports.getBrazilHolidays = getBrazilHolidays;
|
|
19
|
+
exports.getMexicoHolidays = getMexicoHolidays;
|
|
20
|
+
exports.getSouthKoreaHolidays = getSouthKoreaHolidays;
|
|
21
|
+
exports.getSingaporeHolidays = getSingaporeHolidays;
|
|
22
|
+
exports.getPolandHolidays = getPolandHolidays;
|
|
23
|
+
exports.getSwedenHolidays = getSwedenHolidays;
|
|
24
|
+
exports.getBelgiumHolidays = getBelgiumHolidays;
|
|
25
|
+
exports.getSwitzerlandHolidays = getSwitzerlandHolidays;
|
|
26
|
+
exports.getHolidays = getHolidays;
|
|
27
|
+
exports.isHoliday = isHoliday;
|
|
28
|
+
exports.getHolidayName = getHolidayName;
|
|
29
|
+
exports.getNextHoliday = getNextHoliday;
|
|
30
|
+
exports.getUpcomingHolidays = getUpcomingHolidays;
|
|
31
|
+
exports.getSupportedCountries = getSupportedCountries;
|
|
5
32
|
/**
|
|
6
33
|
* Calculate Easter Sunday using the Anonymous Gregorian algorithm
|
|
7
34
|
* @param year - The year
|
|
@@ -64,7 +91,7 @@ function adjustForWeekend(date) {
|
|
|
64
91
|
// ============================================================================
|
|
65
92
|
// UK HOLIDAYS
|
|
66
93
|
// ============================================================================
|
|
67
|
-
|
|
94
|
+
function getUKHolidays(year) {
|
|
68
95
|
const holidays = [];
|
|
69
96
|
// New Year's Day (or substitute)
|
|
70
97
|
holidays.push({
|
|
@@ -139,7 +166,7 @@ export function getUKHolidays(year) {
|
|
|
139
166
|
// ============================================================================
|
|
140
167
|
// NETHERLANDS HOLIDAYS
|
|
141
168
|
// ============================================================================
|
|
142
|
-
|
|
169
|
+
function getNetherlandsHolidays(year) {
|
|
143
170
|
const holidays = [];
|
|
144
171
|
const easter = getEasterSunday(year);
|
|
145
172
|
// New Year's Day
|
|
@@ -235,7 +262,7 @@ export function getNetherlandsHolidays(year) {
|
|
|
235
262
|
// ============================================================================
|
|
236
263
|
// GERMANY HOLIDAYS
|
|
237
264
|
// ============================================================================
|
|
238
|
-
|
|
265
|
+
function getGermanyHolidays(year) {
|
|
239
266
|
const holidays = [];
|
|
240
267
|
const easter = getEasterSunday(year);
|
|
241
268
|
// New Year's Day
|
|
@@ -306,7 +333,7 @@ export function getGermanyHolidays(year) {
|
|
|
306
333
|
// ============================================================================
|
|
307
334
|
// CANADA HOLIDAYS
|
|
308
335
|
// ============================================================================
|
|
309
|
-
|
|
336
|
+
function getCanadaHolidays(year) {
|
|
310
337
|
const holidays = [];
|
|
311
338
|
const easter = getEasterSunday(year);
|
|
312
339
|
// New Year's Day
|
|
@@ -379,7 +406,7 @@ export function getCanadaHolidays(year) {
|
|
|
379
406
|
// ============================================================================
|
|
380
407
|
// AUSTRALIA HOLIDAYS
|
|
381
408
|
// ============================================================================
|
|
382
|
-
|
|
409
|
+
function getAustraliaHolidays(year) {
|
|
383
410
|
const holidays = [];
|
|
384
411
|
const easter = getEasterSunday(year);
|
|
385
412
|
// New Year's Day
|
|
@@ -450,7 +477,7 @@ export function getAustraliaHolidays(year) {
|
|
|
450
477
|
// ============================================================================
|
|
451
478
|
// ITALY HOLIDAYS
|
|
452
479
|
// ============================================================================
|
|
453
|
-
|
|
480
|
+
function getItalyHolidays(year) {
|
|
454
481
|
const holidays = [];
|
|
455
482
|
const easter = getEasterSunday(year);
|
|
456
483
|
// New Year's Day
|
|
@@ -535,7 +562,7 @@ export function getItalyHolidays(year) {
|
|
|
535
562
|
// ============================================================================
|
|
536
563
|
// SPAIN HOLIDAYS
|
|
537
564
|
// ============================================================================
|
|
538
|
-
|
|
565
|
+
function getSpainHolidays(year) {
|
|
539
566
|
const holidays = [];
|
|
540
567
|
const easter = getEasterSunday(year);
|
|
541
568
|
// New Year's Day
|
|
@@ -613,7 +640,7 @@ export function getSpainHolidays(year) {
|
|
|
613
640
|
// ============================================================================
|
|
614
641
|
// CHINA HOLIDAYS (Simplified - some are lunar calendar based)
|
|
615
642
|
// ============================================================================
|
|
616
|
-
|
|
643
|
+
function getChinaHolidays(year) {
|
|
617
644
|
const holidays = [];
|
|
618
645
|
// New Year's Day
|
|
619
646
|
holidays.push({
|
|
@@ -655,7 +682,7 @@ export function getChinaHolidays(year) {
|
|
|
655
682
|
// ============================================================================
|
|
656
683
|
// INDIA HOLIDAYS (Simplified - many are lunar calendar based)
|
|
657
684
|
// ============================================================================
|
|
658
|
-
|
|
685
|
+
function getIndiaHolidays(year) {
|
|
659
686
|
const holidays = [];
|
|
660
687
|
// Republic Day
|
|
661
688
|
holidays.push({
|
|
@@ -685,7 +712,7 @@ export function getIndiaHolidays(year) {
|
|
|
685
712
|
// ============================================================================
|
|
686
713
|
// JAPAN HOLIDAYS
|
|
687
714
|
// ============================================================================
|
|
688
|
-
|
|
715
|
+
function getJapanHolidays(year) {
|
|
689
716
|
const holidays = [];
|
|
690
717
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'JP', type: 'public' });
|
|
691
718
|
holidays.push({ name: 'Coming of Age Day', date: getNthWeekdayOfMonth(year, 0, 1, 2), countryCode: 'JP', type: 'public' });
|
|
@@ -708,7 +735,7 @@ export function getJapanHolidays(year) {
|
|
|
708
735
|
// ============================================================================
|
|
709
736
|
// FRANCE HOLIDAYS
|
|
710
737
|
// ============================================================================
|
|
711
|
-
|
|
738
|
+
function getFranceHolidays(year) {
|
|
712
739
|
const holidays = [];
|
|
713
740
|
const easter = getEasterSunday(year);
|
|
714
741
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'FR', type: 'public' });
|
|
@@ -727,7 +754,7 @@ export function getFranceHolidays(year) {
|
|
|
727
754
|
// ============================================================================
|
|
728
755
|
// BRAZIL HOLIDAYS
|
|
729
756
|
// ============================================================================
|
|
730
|
-
|
|
757
|
+
function getBrazilHolidays(year) {
|
|
731
758
|
const holidays = [];
|
|
732
759
|
const easter = getEasterSunday(year);
|
|
733
760
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'BR', type: 'public' });
|
|
@@ -746,7 +773,7 @@ export function getBrazilHolidays(year) {
|
|
|
746
773
|
// ============================================================================
|
|
747
774
|
// MEXICO HOLIDAYS
|
|
748
775
|
// ============================================================================
|
|
749
|
-
|
|
776
|
+
function getMexicoHolidays(year) {
|
|
750
777
|
const holidays = [];
|
|
751
778
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'MX', type: 'public' });
|
|
752
779
|
holidays.push({ name: 'Constitution Day', date: getNthWeekdayOfMonth(year, 1, 1, 1), countryCode: 'MX', type: 'public' });
|
|
@@ -760,7 +787,7 @@ export function getMexicoHolidays(year) {
|
|
|
760
787
|
// ============================================================================
|
|
761
788
|
// SOUTH KOREA HOLIDAYS
|
|
762
789
|
// ============================================================================
|
|
763
|
-
|
|
790
|
+
function getSouthKoreaHolidays(year) {
|
|
764
791
|
const holidays = [];
|
|
765
792
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'KR', type: 'public' });
|
|
766
793
|
holidays.push({ name: 'Independence Movement Day', date: new Date(year, 2, 1), countryCode: 'KR', type: 'public' });
|
|
@@ -776,7 +803,7 @@ export function getSouthKoreaHolidays(year) {
|
|
|
776
803
|
// ============================================================================
|
|
777
804
|
// SINGAPORE HOLIDAYS
|
|
778
805
|
// ============================================================================
|
|
779
|
-
|
|
806
|
+
function getSingaporeHolidays(year) {
|
|
780
807
|
const holidays = [];
|
|
781
808
|
const easter = getEasterSunday(year);
|
|
782
809
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'SG', type: 'public' });
|
|
@@ -790,7 +817,7 @@ export function getSingaporeHolidays(year) {
|
|
|
790
817
|
// ============================================================================
|
|
791
818
|
// POLAND HOLIDAYS
|
|
792
819
|
// ============================================================================
|
|
793
|
-
|
|
820
|
+
function getPolandHolidays(year) {
|
|
794
821
|
const holidays = [];
|
|
795
822
|
const easter = getEasterSunday(year);
|
|
796
823
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'PL', type: 'public' });
|
|
@@ -811,7 +838,7 @@ export function getPolandHolidays(year) {
|
|
|
811
838
|
// ============================================================================
|
|
812
839
|
// SWEDEN HOLIDAYS
|
|
813
840
|
// ============================================================================
|
|
814
|
-
|
|
841
|
+
function getSwedenHolidays(year) {
|
|
815
842
|
const holidays = [];
|
|
816
843
|
const easter = getEasterSunday(year);
|
|
817
844
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'SE', type: 'public' });
|
|
@@ -851,7 +878,7 @@ function getSaturdayBetween(year, startMonth, startDay, endMonth, endDay) {
|
|
|
851
878
|
// ============================================================================
|
|
852
879
|
// BELGIUM HOLIDAYS
|
|
853
880
|
// ============================================================================
|
|
854
|
-
|
|
881
|
+
function getBelgiumHolidays(year) {
|
|
855
882
|
const holidays = [];
|
|
856
883
|
const easter = getEasterSunday(year);
|
|
857
884
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'BE', type: 'public' });
|
|
@@ -869,7 +896,7 @@ export function getBelgiumHolidays(year) {
|
|
|
869
896
|
// ============================================================================
|
|
870
897
|
// SWITZERLAND HOLIDAYS (Federal only - cantons have additional)
|
|
871
898
|
// ============================================================================
|
|
872
|
-
|
|
899
|
+
function getSwitzerlandHolidays(year) {
|
|
873
900
|
const holidays = [];
|
|
874
901
|
const easter = getEasterSunday(year);
|
|
875
902
|
holidays.push({ name: "New Year's Day", date: new Date(year, 0, 1), countryCode: 'CH', type: 'public' });
|
|
@@ -890,7 +917,7 @@ export function getSwitzerlandHolidays(year) {
|
|
|
890
917
|
* @param countryCode - ISO country code
|
|
891
918
|
* @returns Array of holidays
|
|
892
919
|
*/
|
|
893
|
-
|
|
920
|
+
function getHolidays(year, countryCode) {
|
|
894
921
|
switch (countryCode) {
|
|
895
922
|
case 'UK':
|
|
896
923
|
return getUKHolidays(year);
|
|
@@ -943,7 +970,7 @@ export function getHolidays(year, countryCode) {
|
|
|
943
970
|
* @param countryCode - ISO country code
|
|
944
971
|
* @returns True if date is a holiday
|
|
945
972
|
*/
|
|
946
|
-
|
|
973
|
+
function isHoliday(date, countryCode) {
|
|
947
974
|
const holidays = getHolidays(date.getFullYear(), countryCode);
|
|
948
975
|
// Normalize to local date components for comparison
|
|
949
976
|
const targetYear = date.getFullYear();
|
|
@@ -959,7 +986,7 @@ export function isHoliday(date, countryCode) {
|
|
|
959
986
|
* @param countryCode - ISO country code
|
|
960
987
|
* @returns Holiday name or null if not a holiday
|
|
961
988
|
*/
|
|
962
|
-
|
|
989
|
+
function getHolidayName(date, countryCode) {
|
|
963
990
|
const holidays = getHolidays(date.getFullYear(), countryCode);
|
|
964
991
|
// Normalize to local date components for comparison
|
|
965
992
|
const targetYear = date.getFullYear();
|
|
@@ -976,7 +1003,7 @@ export function getHolidayName(date, countryCode) {
|
|
|
976
1003
|
* @param countryCode - ISO country code
|
|
977
1004
|
* @returns Next holiday or null
|
|
978
1005
|
*/
|
|
979
|
-
|
|
1006
|
+
function getNextHoliday(date, countryCode) {
|
|
980
1007
|
const year = date.getFullYear();
|
|
981
1008
|
let holidays = getHolidays(year, countryCode);
|
|
982
1009
|
// Also get next year's holidays
|
|
@@ -993,7 +1020,7 @@ export function getNextHoliday(date, countryCode) {
|
|
|
993
1020
|
* @param countryCode - ISO country code
|
|
994
1021
|
* @returns Array of upcoming holidays
|
|
995
1022
|
*/
|
|
996
|
-
|
|
1023
|
+
function getUpcomingHolidays(date, days, countryCode) {
|
|
997
1024
|
const year = date.getFullYear();
|
|
998
1025
|
let holidays = getHolidays(year, countryCode);
|
|
999
1026
|
// Also get next year's holidays
|
|
@@ -1007,6 +1034,6 @@ export function getUpcomingHolidays(date, days, countryCode) {
|
|
|
1007
1034
|
* Get all supported country codes
|
|
1008
1035
|
* @returns Array of country codes
|
|
1009
1036
|
*/
|
|
1010
|
-
|
|
1037
|
+
function getSupportedCountries() {
|
|
1011
1038
|
return ['UK', 'NL', 'DE', 'CA', 'AU', 'IT', 'ES', 'CN', 'IN', 'US', 'JP', 'FR', 'BR', 'MX', 'KR', 'SG', 'PL', 'SE', 'BE', 'CH'];
|
|
1012
1039
|
}
|