soff-date 1.0.10 → 1.2.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.
Files changed (70) hide show
  1. package/README.md +82 -12
  2. package/dist/ar-DOBc0AKI.d.ts +24 -0
  3. package/dist/ar-DZGRazxg.d.cts +24 -0
  4. package/dist/br-Bxl7-z70.d.cts +24 -0
  5. package/dist/br-DyXv2cHh.d.ts +24 -0
  6. package/dist/co-BPDNBIJT.d.ts +24 -0
  7. package/dist/co-pYFH0DtD.d.cts +24 -0
  8. package/dist/core/algorithms/easter.cjs +1 -1
  9. package/dist/core/algorithms/easter.cjs.map +1 -1
  10. package/dist/core/algorithms/easter.js +1 -1
  11. package/dist/core/algorithms/easter.js.map +1 -1
  12. package/dist/core/algorithms/nth-weekday.cjs +1 -1
  13. package/dist/core/algorithms/nth-weekday.cjs.map +1 -1
  14. package/dist/core/algorithms/nth-weekday.js +1 -1
  15. package/dist/core/algorithms/nth-weekday.js.map +1 -1
  16. package/dist/core/algorithms/shifts.cjs +1 -1
  17. package/dist/core/algorithms/shifts.cjs.map +1 -1
  18. package/dist/core/algorithms/shifts.js +1 -1
  19. package/dist/core/algorithms/shifts.js.map +1 -1
  20. package/dist/core/engine.cjs +1 -1
  21. package/dist/core/engine.cjs.map +1 -1
  22. package/dist/core/engine.js +1 -1
  23. package/dist/core/engine.js.map +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +24 -1
  27. package/dist/index.d.ts +24 -1
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/locales/ar.cjs +1 -1
  31. package/dist/locales/ar.cjs.map +1 -1
  32. package/dist/locales/ar.d.cts +2 -13
  33. package/dist/locales/ar.d.ts +2 -13
  34. package/dist/locales/ar.js +1 -1
  35. package/dist/locales/ar.js.map +1 -1
  36. package/dist/locales/br.cjs +1 -1
  37. package/dist/locales/br.cjs.map +1 -1
  38. package/dist/locales/br.d.cts +2 -13
  39. package/dist/locales/br.d.ts +2 -13
  40. package/dist/locales/br.js +1 -1
  41. package/dist/locales/br.js.map +1 -1
  42. package/dist/locales/co.cjs +1 -1
  43. package/dist/locales/co.cjs.map +1 -1
  44. package/dist/locales/co.d.cts +2 -13
  45. package/dist/locales/co.d.ts +2 -13
  46. package/dist/locales/co.js +1 -1
  47. package/dist/locales/co.js.map +1 -1
  48. package/dist/locales/index.cjs +2 -0
  49. package/dist/locales/index.cjs.map +1 -0
  50. package/dist/locales/index.d.cts +6 -0
  51. package/dist/locales/index.d.ts +6 -0
  52. package/dist/locales/index.js +2 -0
  53. package/dist/locales/index.js.map +1 -0
  54. package/dist/locales/mx.cjs +1 -1
  55. package/dist/locales/mx.cjs.map +1 -1
  56. package/dist/locales/mx.d.cts +2 -13
  57. package/dist/locales/mx.d.ts +2 -13
  58. package/dist/locales/mx.js +1 -1
  59. package/dist/locales/mx.js.map +1 -1
  60. package/dist/locales/us.cjs +1 -1
  61. package/dist/locales/us.cjs.map +1 -1
  62. package/dist/locales/us.d.cts +2 -13
  63. package/dist/locales/us.d.ts +2 -13
  64. package/dist/locales/us.js +1 -1
  65. package/dist/locales/us.js.map +1 -1
  66. package/dist/mx-AFleoZyO.d.ts +24 -0
  67. package/dist/mx-aI-ieOc4.d.cts +24 -0
  68. package/dist/us-8v1NFxuj.d.cts +24 -0
  69. package/dist/us-BMlmAp3v.d.ts +24 -0
  70. package/package.json +20 -10
package/README.md CHANGED
@@ -31,6 +31,8 @@
31
31
  - [Shift Rules Explained](#shift-rules-explained)
32
32
  - [Emiliani (Colombia, Argentina)](#emiliani-colombia-argentina)
33
33
  - [Observed US (USA, UK)](#observed-us-usa-uk)
34
+ - [Nearest Monday (Argentina)](#nearest-monday-argentina)
35
+ - [Mexico's Presidential Transition Holiday](#mexicos-presidential-transition-holiday)
34
36
  - [Advanced: Create Your Own Locale](#advanced-create-your-own-locale)
35
37
  - [Advanced: Use Algorithms Directly](#advanced-use-algorithms-directly)
36
38
  - [Bundle Size](#bundle-size)
@@ -38,6 +40,7 @@
38
40
  - [`getHolidays(year, options?)`](#getholidaysyear-options)
39
41
  - [`isHoliday(date, options?)`](#isholidaydate-options)
40
42
  - [`getNextHoliday(from?, options?)`](#getnextholidayfrom-options)
43
+ - [`formatRelativeTime(date, options?)`](#formatrelativetimedate-options)
41
44
  - [Business Days Calculation](#business-days-calculation)
42
45
  - [Types](#types)
43
46
  - [Contributing](#contributing)
@@ -111,13 +114,23 @@ getHolidays(2025, { lang: { ...en, newYear: 'Happy New Year!' } });
111
114
 
112
115
  ## Available Locales
113
116
 
114
- | Locale | Import | Holidays | Shift Rule |
115
- | ------------ | ---------------------- | -------- | ---------- |
116
- | 🇨🇴 Colombia | `soff-date/locales/co` | 18 | Emiliani |
117
- | 🇺🇸 USA | `soff-date/locales/us` | 10 | Observed |
118
- | 🇲🇽 México | `soff-date/locales/mx` | 8 | NthWeekday |
119
- | 🇦🇷 Argentina | `soff-date/locales/ar` | 16 | NearestMon |
120
- | 🇧🇷 Brasil | `soff-date/locales/br` | 13 | None |
117
+ | Locale | Import | Holidays | Shift Rule |
118
+ | ------------ | ---------------------- | -------- | ------------------- |
119
+ | 🇨🇴 Colombia | `soff-date/locales/co` | 18 | Emiliani |
120
+ | 🇺🇸 USA | `soff-date/locales/us` | 10 | Observed |
121
+ | 🇲🇽 México | `soff-date/locales/mx` | 8 | NthWeekday + Custom |
122
+ | 🇦🇷 Argentina | `soff-date/locales/ar` | 16 | NearestMonday |
123
+ | 🇧🇷 Brasil | `soff-date/locales/br` | 13 | None |
124
+
125
+ If you need to select a locale dynamically, you can import all locale namespaces from the public barrel:
126
+
127
+ ```typescript
128
+ import { co, mx, us } from 'soff-date/locales';
129
+
130
+ co.getHolidays(2025);
131
+ mx.isHoliday(new Date('2025-09-16'));
132
+ us.getNextHoliday(new Date('2025-07-01'));
133
+ ```
121
134
 
122
135
  ## Available Languages
123
136
 
@@ -148,6 +161,27 @@ Holidays falling on weekends **move to Monday**.
148
161
  { date: '2026-07-03', key: 'independenceDayUS', isShifted: true }
149
162
  ```
150
163
 
164
+ ### Nearest Monday (Argentina)
165
+
166
+ - Tuesday or Wednesday → previous Monday
167
+ - Thursday or Friday → next Monday
168
+ - Monday, Saturday and Sunday stay unchanged
169
+
170
+ ```typescript
171
+ // June 17, 2025 = Tuesday → Monday June 16
172
+ { date: '2025-06-16', key: 'guemesDay', isShifted: true }
173
+
174
+ // November 20, 2025 = Thursday → Monday November 24
175
+ { date: '2025-11-24', key: 'sovereigntyDay', isShifted: true }
176
+ ```
177
+
178
+ ### Mexico's Presidential Transition Holiday
179
+
180
+ Mexico includes a custom holiday for the transmission of executive power.
181
+
182
+ - From 2024 onward, it is observed on October 1 every 6 years: 2024, 2030, 2036, ...
183
+ - For historical years before 2024, the library preserves the previous December 1 cycle: 2018, 2012, ...
184
+
151
185
  ## Advanced: Create Your Own Locale
152
186
 
153
187
  ```typescript
@@ -194,9 +228,7 @@ export function getHolidays(year: number): Holiday[] {
194
228
  ## Advanced: Use Algorithms Directly
195
229
 
196
230
  ```typescript
197
- import { getEasterSunday } from 'soff-date/core/algorithms/easter';
198
- import { getNthWeekday } from 'soff-date/core/algorithms/nth-weekday';
199
- import { applyShift } from 'soff-date/core/algorithms/shifts';
231
+ import { getEasterSunday, getNthWeekday, applyShift } from 'soff-date';
200
232
 
201
233
  // Easter Sunday 2025
202
234
  getEasterSunday(2025); // → Date(2025, 3, 20)
@@ -209,6 +241,12 @@ applyShift(new Date('2026-07-04'), 'observedUS');
209
241
  // → { date: Date(2026-07-03), shifted: true }
210
242
  ```
211
243
 
244
+ `getNthWeekday()` returns `Invalid Date` when the requested occurrence does not exist in the target month or when the input is out of range.
245
+
246
+ `getEasterSunday()` returns `Invalid Date` for unsupported years outside the Gregorian calendar (`< 1583`) and for non-integer years.
247
+
248
+ `applyShift()` preserves `Invalid Date` inputs and returns `shifted: false` instead of marking a move on invalid data.
249
+
212
250
  ## Bundle Size
213
251
 
214
252
  | Import | Size (minified) |
@@ -242,6 +280,8 @@ interface Holiday {
242
280
  }
243
281
  ```
244
282
 
283
+ `year` must be an integer. Non-integer values return an empty array.
284
+
245
285
  ### `isHoliday(date, options?)`
246
286
 
247
287
  Returns holiday info if the date is a holiday, `null` otherwise.
@@ -250,6 +290,29 @@ Returns holiday info if the date is a holiday, `null` otherwise.
250
290
 
251
291
  Returns the next holiday from a given date (defaults to today).
252
292
 
293
+ ### `formatRelativeTime(date, options?)`
294
+
295
+ Formats a date relative to another date using `Intl.RelativeTimeFormat`.
296
+
297
+ ```typescript
298
+ import { formatRelativeTime } from 'soff-date';
299
+
300
+ formatRelativeTime(new Date('2024-01-02T12:00:00Z'), {
301
+ baseDate: new Date('2024-01-01T12:00:00Z'),
302
+ locale: 'en',
303
+ });
304
+ // → in 1 day
305
+
306
+ formatRelativeTime(new Date('2024-01-01T12:00:00Z'), {
307
+ baseDate: new Date('2024-01-02T12:00:00Z'),
308
+ locale: 'en',
309
+ numeric: 'auto',
310
+ });
311
+ // → yesterday
312
+ ```
313
+
314
+ Returns an empty string for invalid dates instead of throwing.
315
+
253
316
  ## Business Days Calculation
254
317
 
255
318
  In addition to holiday calculation, `soff-date` provides utilities to work with business days (skipping weekends and holidays).
@@ -271,16 +334,23 @@ diffBusinessDays(new Date('2025-01-06'), new Date('2025-01-10'));
271
334
  // → 4
272
335
  ```
273
336
 
337
+ Invalid inputs are handled safely:
338
+
339
+ - `isBusinessDay(invalidDate)` returns `false`
340
+ - `businessDays(invalidDate, amount)` returns `Invalid Date`
341
+ - `businessDays(date, Infinity)` returns `Invalid Date`
342
+ - `diffBusinessDays(invalidDate, date)` returns `NaN`
343
+
274
344
  ## Types
275
345
 
276
346
  ```typescript
277
- type ShiftRule = 'none' | 'emiliani' | 'observedUS' | 'nextMonday';
347
+ type ShiftRule = 'none' | 'emiliani' | 'observedUS' | 'nextMonday' | 'nearestMonday';
278
348
 
279
349
  type HolidayRule =
280
350
  | { type: 'fixed'; month: number; day: number }
281
351
  | { type: 'nthWeekday'; month: number; weekday: number; n: number }
282
352
  | { type: 'easterRelative'; offset: number }
283
- | { type: 'custom'; calc: (year: number) => Date };
353
+ | { type: 'custom'; calc: (year: number) => Date | null };
284
354
 
285
355
  interface HolidayDefinition {
286
356
  key: string;
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.js';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type ar_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const ar_businessDays: typeof businessDays;
15
+ declare const ar_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const ar_getHolidays: typeof getHolidays;
17
+ declare const ar_getNextHoliday: typeof getNextHoliday;
18
+ declare const ar_isBusinessDay: typeof isBusinessDay;
19
+ declare const ar_isHoliday: typeof isHoliday;
20
+ declare namespace ar {
21
+ export { type ar_GetHolidaysOptions as GetHolidaysOptions, ar_businessDays as businessDays, ar_diffBusinessDays as diffBusinessDays, ar_getHolidays as getHolidays, ar_getNextHoliday as getNextHoliday, ar_isBusinessDay as isBusinessDay, ar_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, ar as a, businessDays as b, getNextHoliday as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.cjs';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type ar_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const ar_businessDays: typeof businessDays;
15
+ declare const ar_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const ar_getHolidays: typeof getHolidays;
17
+ declare const ar_getNextHoliday: typeof getNextHoliday;
18
+ declare const ar_isBusinessDay: typeof isBusinessDay;
19
+ declare const ar_isHoliday: typeof isHoliday;
20
+ declare namespace ar {
21
+ export { type ar_GetHolidaysOptions as GetHolidaysOptions, ar_businessDays as businessDays, ar_diffBusinessDays as diffBusinessDays, ar_getHolidays as getHolidays, ar_getNextHoliday as getNextHoliday, ar_isBusinessDay as isBusinessDay, ar_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, ar as a, businessDays as b, getNextHoliday as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.cjs';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type br_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const br_businessDays: typeof businessDays;
15
+ declare const br_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const br_getHolidays: typeof getHolidays;
17
+ declare const br_getNextHoliday: typeof getNextHoliday;
18
+ declare const br_isBusinessDay: typeof isBusinessDay;
19
+ declare const br_isHoliday: typeof isHoliday;
20
+ declare namespace br {
21
+ export { type br_GetHolidaysOptions as GetHolidaysOptions, br_businessDays as businessDays, br_diffBusinessDays as diffBusinessDays, br_getHolidays as getHolidays, br_getNextHoliday as getNextHoliday, br_isBusinessDay as isBusinessDay, br_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, businessDays as a, br as b, getNextHoliday as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.js';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type br_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const br_businessDays: typeof businessDays;
15
+ declare const br_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const br_getHolidays: typeof getHolidays;
17
+ declare const br_getNextHoliday: typeof getNextHoliday;
18
+ declare const br_isBusinessDay: typeof isBusinessDay;
19
+ declare const br_isHoliday: typeof isHoliday;
20
+ declare namespace br {
21
+ export { type br_GetHolidaysOptions as GetHolidaysOptions, br_businessDays as businessDays, br_diffBusinessDays as diffBusinessDays, br_getHolidays as getHolidays, br_getNextHoliday as getNextHoliday, br_isBusinessDay as isBusinessDay, br_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, businessDays as a, br as b, getNextHoliday as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.js';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type co_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const co_businessDays: typeof businessDays;
15
+ declare const co_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const co_getHolidays: typeof getHolidays;
17
+ declare const co_getNextHoliday: typeof getNextHoliday;
18
+ declare const co_isBusinessDay: typeof isBusinessDay;
19
+ declare const co_isHoliday: typeof isHoliday;
20
+ declare namespace co {
21
+ export { type co_GetHolidaysOptions as GetHolidaysOptions, co_businessDays as businessDays, co_diffBusinessDays as diffBusinessDays, co_getHolidays as getHolidays, co_getNextHoliday as getNextHoliday, co_isBusinessDay as isBusinessDay, co_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, getNextHoliday as a, businessDays as b, co as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -0,0 +1,24 @@
1
+ import { HolidayNames, Holiday } from './core/types.cjs';
2
+
3
+ interface GetHolidaysOptions {
4
+ lang?: HolidayNames;
5
+ }
6
+ declare function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[];
7
+ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null;
8
+ declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
+ declare function isBusinessDay(date: Date): boolean;
10
+ declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
12
+
13
+ type co_GetHolidaysOptions = GetHolidaysOptions;
14
+ declare const co_businessDays: typeof businessDays;
15
+ declare const co_diffBusinessDays: typeof diffBusinessDays;
16
+ declare const co_getHolidays: typeof getHolidays;
17
+ declare const co_getNextHoliday: typeof getNextHoliday;
18
+ declare const co_isBusinessDay: typeof isBusinessDay;
19
+ declare const co_isHoliday: typeof isHoliday;
20
+ declare namespace co {
21
+ export { type co_GetHolidaysOptions as GetHolidaysOptions, co_businessDays as businessDays, co_diffBusinessDays as diffBusinessDays, co_getHolidays as getHolidays, co_getNextHoliday as getNextHoliday, co_isBusinessDay as isBusinessDay, co_isHoliday as isHoliday };
22
+ }
23
+
24
+ export { type GetHolidaysOptions as G, getNextHoliday as a, businessDays as b, co as c, diffBusinessDays as d, isHoliday as e, getHolidays as g, isBusinessDay as i };
@@ -1,2 +1,2 @@
1
- 'use strict';function D(t){let s=t%19,o=Math.floor(t/100),a=t%100,h=Math.floor(o/4),r=o%4,l=Math.floor((o+8)/25),e=Math.floor((o-l+1)/3),n=(19*s+o-h-e+15)%30,M=Math.floor(a/4),u=a%4,c=(32+2*r+2*M-n-u)%7,f=Math.floor((s+11*n+22*c)/451),d=Math.floor((n+c-7*f+114)/31),m=(n+c-7*f+114)%31+1;return new Date(Date.UTC(t,d-1,m))}exports.getEasterSunday=D;//# sourceMappingURL=easter.cjs.map
1
+ 'use strict';function i(t){if(!Number.isInteger(t)||t<1583)return new Date(Number.NaN);let s=t%19,o=Math.floor(t/100),e=t%100,a=Math.floor(o/4),f=o%4,h=Math.floor((o+8)/25),l=Math.floor((o-h+1)/3),n=(19*s+o-a-l+15)%30,u=Math.floor(e/4),M=e%4,c=(32+2*f+2*u-n-M)%7,r=Math.floor((s+11*n+22*c)/451),m=Math.floor((n+c-7*r+114)/31),b=(n+c-7*r+114)%31+1;return new Date(Date.UTC(t,m-1,b))}exports.getEasterSunday=i;//# sourceMappingURL=easter.cjs.map
2
2
  //# sourceMappingURL=easter.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorith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,IAAA,CAAK,GAAA,CAAIZ,EAAMa,CAAAA,CAAQ,CAAA,CAAGC,CAAG,CAAC,CAChD","file":"easter.cjs","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/easter.ts"],"names":["getEasterSunday","year","a","b","c","d","e","f","g","h","i","k","l","m","month","day"],"mappings":"aAIO,SAASA,CAAAA,CAAgBC,CAAAA,CAAoB,CAClD,GAAI,CAAC,MAAA,CAAO,SAAA,CAAUA,CAAI,CAAA,EAAKA,CAAAA,CAAO,IAAA,CACpC,OAAO,IAAI,KAAK,MAAA,CAAO,GAAG,CAAA,CAG5B,IAAMC,CAAAA,CAAID,CAAAA,CAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAO,GAAG,CAAA,CACzBG,CAAAA,CAAIH,EAAO,GAAA,CACXI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAI,CAAC,CAAA,CACpBG,CAAAA,CAAIH,CAAAA,CAAI,CAAA,CACRI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOJ,CAAAA,CAAI,CAAA,EAAK,EAAE,CAAA,CAC3BK,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,CAAAA,CAAAA,CAAK,EAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIE,CAAAA,CAAIG,EAAI,EAAA,EAAM,EAAA,CAChCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMN,CAAAA,CAAI,CAAC,CAAA,CACpBO,CAAAA,CAAIP,CAAAA,CAAI,CAAA,CACRQ,CAAAA,CAAAA,CAAK,EAAA,CAAK,CAAA,CAAIN,EAAI,CAAA,CAAII,CAAAA,CAAID,CAAAA,CAAIE,CAAAA,EAAK,CAAA,CACnCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOX,CAAAA,CAAI,EAAA,CAAKO,CAAAA,CAAI,EAAA,CAAKG,CAAAA,EAAK,GAAG,EAC1CE,CAAAA,CAAQ,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAIG,CAAAA,CAAI,CAAA,CAAIC,CAAAA,CAAI,GAAA,EAAO,EAAE,CAAA,CAC7CE,CAAAA,CAAAA,CAAQN,CAAAA,CAAIG,CAAAA,CAAI,CAAA,CAAIC,CAAAA,CAAI,GAAA,EAAO,EAAA,CAAM,CAAA,CAE3C,OAAO,IAAI,IAAA,CAAK,IAAA,CAAK,GAAA,CAAIZ,CAAAA,CAAMa,CAAAA,CAAQ,CAAA,CAAGC,CAAG,CAAC,CAChD","file":"easter.cjs","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n if (!Number.isInteger(year) || year < 1583) {\n return new Date(Number.NaN);\n }\n\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n"]}
@@ -1,2 +1,2 @@
1
- function D(t){let s=t%19,o=Math.floor(t/100),a=t%100,h=Math.floor(o/4),r=o%4,l=Math.floor((o+8)/25),e=Math.floor((o-l+1)/3),n=(19*s+o-h-e+15)%30,M=Math.floor(a/4),u=a%4,c=(32+2*r+2*M-n-u)%7,f=Math.floor((s+11*n+22*c)/451),d=Math.floor((n+c-7*f+114)/31),m=(n+c-7*f+114)%31+1;return new Date(Date.UTC(t,d-1,m))}export{D as getEasterSunday};//# sourceMappingURL=easter.js.map
1
+ function i(t){if(!Number.isInteger(t)||t<1583)return new Date(Number.NaN);let s=t%19,o=Math.floor(t/100),e=t%100,a=Math.floor(o/4),f=o%4,h=Math.floor((o+8)/25),l=Math.floor((o-h+1)/3),n=(19*s+o-a-l+15)%30,u=Math.floor(e/4),M=e%4,c=(32+2*f+2*u-n-M)%7,r=Math.floor((s+11*n+22*c)/451),m=Math.floor((n+c-7*r+114)/31),b=(n+c-7*r+114)%31+1;return new Date(Date.UTC(t,m-1,b))}export{i as getEasterSunday};//# sourceMappingURL=easter.js.map
2
2
  //# sourceMappingURL=easter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorithms/easter.ts"],"names":["getEasterSunday","year","a","b","c","d","e","f","g","h","i","k","l","m","month","day"],"mappings":"AAIO,SAASA,CAAAA,CAAgBC,EAAoB,CAClD,IAAMC,EAAID,CAAAA,CAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAO,GAAG,CAAA,CACzBG,CAAAA,CAAIH,CAAAA,CAAO,GAAA,CACXI,CAAAA,CAAI,IAAA,CAAK,MAAMF,CAAAA,CAAI,CAAC,CAAA,CACpBG,CAAAA,CAAIH,CAAAA,CAAI,CAAA,CACRI,EAAI,IAAA,CAAK,KAAA,CAAA,CAAOJ,EAAI,CAAA,EAAK,EAAE,EAC3BK,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,CAAAA,CAAAA,CAAK,EAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIE,CAAAA,CAAIG,EAAI,EAAA,EAAM,EAAA,CAChCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMN,CAAAA,CAAI,CAAC,CAAA,CACpBO,CAAAA,CAAIP,EAAI,CAAA,CACRQ,CAAAA,CAAAA,CAAK,GAAK,CAAA,CAAIN,CAAAA,CAAI,CAAA,CAAII,CAAAA,CAAID,CAAAA,CAAIE,CAAAA,EAAK,EACnCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOX,CAAAA,CAAI,EAAA,CAAKO,CAAAA,CAAI,GAAKG,CAAAA,EAAK,GAAG,CAAA,CAC1CE,CAAAA,CAAQ,IAAA,CAAK,KAAA,CAAA,CAAOL,EAAIG,CAAAA,CAAI,CAAA,CAAIC,EAAI,GAAA,EAAO,EAAE,EAC7CE,CAAAA,CAAAA,CAAQN,CAAAA,CAAIG,CAAAA,CAAI,CAAA,CAAIC,CAAAA,CAAI,GAAA,EAAO,GAAM,CAAA,CAE3C,OAAO,IAAI,IAAA,CAAK,IAAA,CAAK,GAAA,CAAIZ,EAAMa,CAAAA,CAAQ,CAAA,CAAGC,CAAG,CAAC,CAChD","file":"easter.js","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/easter.ts"],"names":["getEasterSunday","year","a","b","c","d","e","f","g","h","i","k","l","m","month","day"],"mappings":"AAIO,SAASA,CAAAA,CAAgBC,CAAAA,CAAoB,CAClD,GAAI,CAAC,MAAA,CAAO,SAAA,CAAUA,CAAI,CAAA,EAAKA,CAAAA,CAAO,IAAA,CACpC,OAAO,IAAI,KAAK,MAAA,CAAO,GAAG,CAAA,CAG5B,IAAMC,CAAAA,CAAID,CAAAA,CAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAO,GAAG,CAAA,CACzBG,CAAAA,CAAIH,EAAO,GAAA,CACXI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAI,CAAC,CAAA,CACpBG,CAAAA,CAAIH,CAAAA,CAAI,CAAA,CACRI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOJ,CAAAA,CAAI,CAAA,EAAK,EAAE,CAAA,CAC3BK,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,CAAAA,CAAAA,CAAK,EAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIE,CAAAA,CAAIG,EAAI,EAAA,EAAM,EAAA,CAChCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMN,CAAAA,CAAI,CAAC,CAAA,CACpBO,CAAAA,CAAIP,CAAAA,CAAI,CAAA,CACRQ,CAAAA,CAAAA,CAAK,EAAA,CAAK,CAAA,CAAIN,EAAI,CAAA,CAAII,CAAAA,CAAID,CAAAA,CAAIE,CAAAA,EAAK,CAAA,CACnCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOX,CAAAA,CAAI,EAAA,CAAKO,CAAAA,CAAI,EAAA,CAAKG,CAAAA,EAAK,GAAG,EAC1CE,CAAAA,CAAQ,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAIG,CAAAA,CAAI,CAAA,CAAIC,CAAAA,CAAI,GAAA,EAAO,EAAE,CAAA,CAC7CE,CAAAA,CAAAA,CAAQN,CAAAA,CAAIG,CAAAA,CAAI,CAAA,CAAIC,CAAAA,CAAI,GAAA,EAAO,EAAA,CAAM,CAAA,CAE3C,OAAO,IAAI,IAAA,CAAK,IAAA,CAAK,GAAA,CAAIZ,CAAAA,CAAMa,CAAAA,CAAQ,CAAA,CAAGC,CAAG,CAAC,CAChD","file":"easter.js","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n if (!Number.isInteger(year) || year < 1583) {\n return new Date(Number.NaN);\n }\n\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';function r(e,t,D,a){if(a>0){let f=new Date(Date.UTC(e,t-1,1)).getUTCDay(),s=1+(D-f+7)%7+(a-1)*7;return new Date(Date.UTC(e,t-1,s))}else {let n=new Date(Date.UTC(e,t,0)),c=(n.getUTCDay()-D+7)%7,s=n.getUTCDate()-c+(a+1)*7;return new Date(Date.UTC(e,t-1,s))}}exports.getNthWeekday=r;//# sourceMappingURL=nth-weekday.cjs.map
1
+ 'use strict';function i(t,e,s,n){if(!Number.isInteger(t)||!Number.isInteger(e)||e<1||e>12||!Number.isInteger(s)||s<0||s>6||!Number.isInteger(n)||n===0)return new Date(Number.NaN);let D=e-1;if(n>0){let N=new Date(Date.UTC(t,e-1,1)).getUTCDay(),u=1+(s-N+7)%7+(n-1)*7,r=new Date(Date.UTC(t,e-1,u));return r.getUTCMonth()===D?r:new Date(Number.NaN)}else {let a=new Date(Date.UTC(t,e,0)),c=(a.getUTCDay()-s+7)%7,u=a.getUTCDate()-c+(n+1)*7,r=new Date(Date.UTC(t,e-1,u));return r.getUTCMonth()===D?r:new Date(Number.NaN)}}exports.getNthWeekday=i;//# sourceMappingURL=nth-weekday.cjs.map
2
2
  //# sourceMappingURL=nth-weekday.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorithms/nth-weekday.ts"],"names":["getNthWeekday","year","month","weekday","n","firstWeekday","day","last","diff"],"mappings":"aAOO,SAASA,EAAcC,CAAAA,CAAcC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAAiB,CAC3F,GAAIA,CAAAA,CAAI,CAAA,CAAG,CAGT,IAAMC,CAAAA,CADQ,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIJ,EAAMC,CAAAA,CAAQ,CAAA,CAAG,CAAC,CAAC,EACxB,SAAA,EAAU,CAE/BI,EAAM,CAAA,CAAA,CADEH,CAAAA,CAAUE,EAAe,CAAA,EAAK,CAAA,CAAA,CACpBD,CAAAA,CAAI,CAAA,EAAK,EACjC,OAAO,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIH,EAAMC,CAAAA,CAAQ,CAAA,CAAGI,CAAG,CAAC,CAChD,CAAA,KAAO,CAGL,IAAMC,CAAAA,CAAO,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIN,CAAAA,CAAMC,CAAAA,CAAO,CAAC,CAAC,CAAA,CAExCM,GADcD,CAAAA,CAAK,SAAA,GACGJ,CAAAA,CAAU,CAAA,EAAK,CAAA,CACrCG,CAAAA,CAAMC,EAAK,UAAA,EAAW,CAAIC,GAAQJ,CAAAA,CAAI,CAAA,EAAK,EACjD,OAAO,IAAI,IAAA,CAAK,IAAA,CAAK,IAAIH,CAAAA,CAAMC,CAAAA,CAAQ,EAAGI,CAAG,CAAC,CAChD,CACF","file":"nth-weekday.cjs","sourcesContent":["/**\n * Calculates the Nth weekday of a month\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/nth-weekday.ts"],"names":["getNthWeekday","year","month","weekday","expectedMonth","firstWeekday","day","result","last","diff"],"mappings":"aAOO,SAASA,CAAAA,CAAcC,CAAAA,CAAcC,CAAAA,CAAeC,CAAAA,CAAiB,EAAiB,CAC3F,GACE,CAAC,MAAA,CAAO,SAAA,CAAUF,CAAI,CAAA,EACtB,CAAC,OAAO,SAAA,CAAUC,CAAK,CAAA,EACvBA,CAAAA,CAAQ,CAAA,EACRA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,CAAAA,CAAO,WAAA,EAAY,GAAMH,CAAAA,CAAgBG,EAAS,IAAI,IAAA,CAAK,MAAA,CAAO,GAAG,CAC9E,CACF","file":"nth-weekday.cjs","sourcesContent":["/**\n * Calculates the Nth weekday of a month\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (\n !Number.isInteger(year) ||\n !Number.isInteger(month) ||\n month < 1 ||\n month > 12 ||\n !Number.isInteger(weekday) ||\n weekday < 0 ||\n weekday > 6 ||\n !Number.isInteger(n) ||\n n === 0\n ) {\n return new Date(Number.NaN);\n }\n\n const expectedMonth = month - 1;\n\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- function r(e,t,D,a){if(a>0){let f=new Date(Date.UTC(e,t-1,1)).getUTCDay(),s=1+(D-f+7)%7+(a-1)*7;return new Date(Date.UTC(e,t-1,s))}else {let n=new Date(Date.UTC(e,t,0)),c=(n.getUTCDay()-D+7)%7,s=n.getUTCDate()-c+(a+1)*7;return new Date(Date.UTC(e,t-1,s))}}export{r as getNthWeekday};//# sourceMappingURL=nth-weekday.js.map
1
+ function i(t,e,s,n){if(!Number.isInteger(t)||!Number.isInteger(e)||e<1||e>12||!Number.isInteger(s)||s<0||s>6||!Number.isInteger(n)||n===0)return new Date(Number.NaN);let D=e-1;if(n>0){let N=new Date(Date.UTC(t,e-1,1)).getUTCDay(),u=1+(s-N+7)%7+(n-1)*7,r=new Date(Date.UTC(t,e-1,u));return r.getUTCMonth()===D?r:new Date(Number.NaN)}else {let a=new Date(Date.UTC(t,e,0)),c=(a.getUTCDay()-s+7)%7,u=a.getUTCDate()-c+(n+1)*7,r=new Date(Date.UTC(t,e-1,u));return r.getUTCMonth()===D?r:new Date(Number.NaN)}}export{i as getNthWeekday};//# sourceMappingURL=nth-weekday.js.map
2
2
  //# sourceMappingURL=nth-weekday.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorithms/nth-weekday.ts"],"names":["getNthWeekday","year","month","weekday","n","firstWeekday","day","last","diff"],"mappings":"AAOO,SAASA,EAAcC,CAAAA,CAAcC,CAAAA,CAAeC,CAAAA,CAAiBC,CAAAA,CAAiB,CAC3F,GAAIA,CAAAA,CAAI,CAAA,CAAG,CAGT,IAAMC,CAAAA,CADQ,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIJ,EAAMC,CAAAA,CAAQ,CAAA,CAAG,CAAC,CAAC,EACxB,SAAA,EAAU,CAE/BI,EAAM,CAAA,CAAA,CADEH,CAAAA,CAAUE,EAAe,CAAA,EAAK,CAAA,CAAA,CACpBD,CAAAA,CAAI,CAAA,EAAK,EACjC,OAAO,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIH,EAAMC,CAAAA,CAAQ,CAAA,CAAGI,CAAG,CAAC,CAChD,CAAA,KAAO,CAGL,IAAMC,CAAAA,CAAO,IAAI,KAAK,IAAA,CAAK,GAAA,CAAIN,CAAAA,CAAMC,CAAAA,CAAO,CAAC,CAAC,CAAA,CAExCM,GADcD,CAAAA,CAAK,SAAA,GACGJ,CAAAA,CAAU,CAAA,EAAK,CAAA,CACrCG,CAAAA,CAAMC,EAAK,UAAA,EAAW,CAAIC,GAAQJ,CAAAA,CAAI,CAAA,EAAK,EACjD,OAAO,IAAI,IAAA,CAAK,IAAA,CAAK,IAAIH,CAAAA,CAAMC,CAAAA,CAAQ,EAAGI,CAAG,CAAC,CAChD,CACF","file":"nth-weekday.js","sourcesContent":["/**\n * Calculates the Nth weekday of a month\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n }\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/nth-weekday.ts"],"names":["getNthWeekday","year","month","weekday","expectedMonth","firstWeekday","day","result","last","diff"],"mappings":"AAOO,SAASA,CAAAA,CAAcC,CAAAA,CAAcC,CAAAA,CAAeC,CAAAA,CAAiB,EAAiB,CAC3F,GACE,CAAC,MAAA,CAAO,SAAA,CAAUF,CAAI,CAAA,EACtB,CAAC,OAAO,SAAA,CAAUC,CAAK,CAAA,EACvBA,CAAAA,CAAQ,CAAA,EACRA,CAAAA,CAAQ,EAAA,EACR,CAAC,OAAO,SAAA,CAAUC,CAAO,CAAA,EACzBA,CAAAA,CAAU,GACVA,CAAAA,CAAU,CAAA,EACV,CAAC,MAAA,CAAO,UAAU,CAAC,CAAA,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\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (\n !Number.isInteger(year) ||\n !Number.isInteger(month) ||\n month < 1 ||\n month > 12 ||\n !Number.isInteger(weekday) ||\n weekday < 0 ||\n weekday > 6 ||\n !Number.isInteger(n) ||\n n === 0\n ) {\n return new Date(Number.NaN);\n }\n\n const expectedMonth = month - 1;\n\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';function i(e,a){let t=e.getUTCDay();if(a==="none")return {date:e,shifted:false};let s=new Date(e);switch(a){case "emiliani":case "nextMonday":{if(t===1)return {date:e,shifted:false};let f=(8-t)%7;s.setUTCDate(e.getUTCDate()+f);break}case "observedUS":if(t===0)s.setUTCDate(e.getUTCDate()+1);else if(t===6)s.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(t===2)s.setUTCDate(e.getUTCDate()-1);else if(t===3)s.setUTCDate(e.getUTCDate()-2);else if(t===4)s.setUTCDate(e.getUTCDate()+4);else if(t===5)s.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:s,shifted:true}}exports.applyShift=i;//# sourceMappingURL=shifts.cjs.map
1
+ 'use strict';function f(e){return e instanceof Date&&Number.isFinite(e.getTime())}function n(e,i){if(!f(e))return {date:e,shifted:false};let t=e.getUTCDay();if(i==="none")return {date:e,shifted:false};let s=new Date(e);switch(i){case "emiliani":case "nextMonday":{if(t===1)return {date:e,shifted:false};let a=(8-t)%7;s.setUTCDate(e.getUTCDate()+a);break}case "observedUS":if(t===0)s.setUTCDate(e.getUTCDate()+1);else if(t===6)s.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(t===2)s.setUTCDate(e.getUTCDate()-1);else if(t===3)s.setUTCDate(e.getUTCDate()-2);else if(t===4)s.setUTCDate(e.getUTCDate()+4);else if(t===5)s.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:s,shifted:true}}exports.applyShift=n;//# sourceMappingURL=shifts.cjs.map
2
2
  //# sourceMappingURL=shifts.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorithms/shifts.ts"],"names":["applyShift","date","rule","day","result","daysToNextMonday"],"mappings":"aAMO,SAASA,CAAAA,CAAWC,CAAAA,CAAYC,CAAAA,CAAmD,CACxF,IAAMC,CAAAA,CAAMF,CAAAA,CAAK,SAAA,EAAU,CAE3B,GAAIC,CAAAA,GAAS,MAAA,CACX,OAAO,CAAE,KAAAD,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAGhC,IAAMG,CAAAA,CAAS,IAAI,IAAA,CAAKH,CAAI,CAAA,CAE5B,OAAQC,CAAAA,EACN,KAAK,UAAA,CACL,KAAK,YAAA,CAAc,CAEjB,GAAIC,CAAAA,GAAQ,CAAA,CACV,OAAO,CAAE,IAAA,CAAAF,CAAAA,CAAM,OAAA,CAAS,KAAM,EAOhC,IAAMI,CAAAA,CAAAA,CAAoB,CAAA,CAAIF,CAAAA,EAAO,EACrCC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAeI,CAAgB,CAAA,CACtD,KACF,CAEA,KAAK,YAAA,CAEH,GAAIF,CAAAA,GAAQ,EAEVC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAEvC,OAAO,CAAE,KAAAA,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAEhC,MAEF,KAAK,eAAA,CAIH,GAAIE,CAAAA,GAAQ,EAEVC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,EAEjBC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAEvC,OAAO,CAAE,IAAA,CAAAA,EAAM,OAAA,CAAS,KAAM,CAAA,CAEhC,MAEF,QACE,OAAO,CAAE,IAAA,CAAAA,EAAM,OAAA,CAAS,KAAM,CAClC,CAEA,OAAO,CAAE,IAAA,CAAMG,CAAAA,CAAQ,OAAA,CAAS,IAAK,CACvC","file":"shifts.cjs","sourcesContent":["import type { ShiftRule } from '../types';\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/shifts.ts"],"names":["isValidDate","date","applyShift","rule","day","result","daysToNextMonday"],"mappings":"aAEA,SAASA,EAAYC,CAAAA,CAAqB,CACxC,OAAOA,CAAAA,YAAgB,IAAA,EAAQ,OAAO,QAAA,CAASA,CAAAA,CAAK,OAAA,EAAS,CAC/D,CAMO,SAASC,EAAWD,CAAAA,CAAYE,CAAAA,CAAmD,CACxF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jBC,EAAO,UAAA,CAAWJ,CAAAA,CAAK,YAAW,CAAI,CAAC,OAEvC,OAAO,CAAE,IAAA,CAAAA,CAAAA,CAAM,QAAS,KAAM,CAAA,CAEhC,MAEF,QACE,OAAO,CAAE,IAAA,CAAAA,CAAAA,CAAM,QAAS,KAAM,CAClC,CAEA,OAAO,CAAE,KAAMI,CAAAA,CAAQ,OAAA,CAAS,IAAK,CACvC","file":"shifts.cjs","sourcesContent":["import type { ShiftRule } from '../types';\n\nfunction isValidDate(date: Date): boolean {\n return date instanceof Date && Number.isFinite(date.getTime());\n}\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n if (!isValidDate(date)) {\n return { date, shifted: false };\n }\n\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n"]}
@@ -1,2 +1,2 @@
1
- function i(e,a){let t=e.getUTCDay();if(a==="none")return {date:e,shifted:false};let s=new Date(e);switch(a){case "emiliani":case "nextMonday":{if(t===1)return {date:e,shifted:false};let f=(8-t)%7;s.setUTCDate(e.getUTCDate()+f);break}case "observedUS":if(t===0)s.setUTCDate(e.getUTCDate()+1);else if(t===6)s.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(t===2)s.setUTCDate(e.getUTCDate()-1);else if(t===3)s.setUTCDate(e.getUTCDate()-2);else if(t===4)s.setUTCDate(e.getUTCDate()+4);else if(t===5)s.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:s,shifted:true}}export{i as applyShift};//# sourceMappingURL=shifts.js.map
1
+ function f(e){return e instanceof Date&&Number.isFinite(e.getTime())}function n(e,i){if(!f(e))return {date:e,shifted:false};let t=e.getUTCDay();if(i==="none")return {date:e,shifted:false};let s=new Date(e);switch(i){case "emiliani":case "nextMonday":{if(t===1)return {date:e,shifted:false};let a=(8-t)%7;s.setUTCDate(e.getUTCDate()+a);break}case "observedUS":if(t===0)s.setUTCDate(e.getUTCDate()+1);else if(t===6)s.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(t===2)s.setUTCDate(e.getUTCDate()-1);else if(t===3)s.setUTCDate(e.getUTCDate()-2);else if(t===4)s.setUTCDate(e.getUTCDate()+4);else if(t===5)s.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:s,shifted:true}}export{n as applyShift};//# sourceMappingURL=shifts.js.map
2
2
  //# sourceMappingURL=shifts.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/core/algorithms/shifts.ts"],"names":["applyShift","date","rule","day","result","daysToNextMonday"],"mappings":"AAMO,SAASA,CAAAA,CAAWC,CAAAA,CAAYC,CAAAA,CAAmD,CACxF,IAAMC,CAAAA,CAAMF,CAAAA,CAAK,SAAA,EAAU,CAE3B,GAAIC,CAAAA,GAAS,MAAA,CACX,OAAO,CAAE,KAAAD,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAGhC,IAAMG,CAAAA,CAAS,IAAI,IAAA,CAAKH,CAAI,CAAA,CAE5B,OAAQC,CAAAA,EACN,KAAK,UAAA,CACL,KAAK,YAAA,CAAc,CAEjB,GAAIC,CAAAA,GAAQ,CAAA,CACV,OAAO,CAAE,IAAA,CAAAF,CAAAA,CAAM,OAAA,CAAS,KAAM,EAOhC,IAAMI,CAAAA,CAAAA,CAAoB,CAAA,CAAIF,CAAAA,EAAO,EACrCC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAeI,CAAgB,CAAA,CACtD,KACF,CAEA,KAAK,YAAA,CAEH,GAAIF,CAAAA,GAAQ,EAEVC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAEvC,OAAO,CAAE,KAAAA,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAEhC,MAEF,KAAK,eAAA,CAIH,GAAIE,CAAAA,GAAQ,EAEVC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,EAEjBC,CAAAA,CAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BE,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWH,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAEvC,OAAO,CAAE,IAAA,CAAAA,EAAM,OAAA,CAAS,KAAM,CAAA,CAEhC,MAEF,QACE,OAAO,CAAE,IAAA,CAAAA,EAAM,OAAA,CAAS,KAAM,CAClC,CAEA,OAAO,CAAE,IAAA,CAAMG,CAAAA,CAAQ,OAAA,CAAS,IAAK,CACvC","file":"shifts.js","sourcesContent":["import type { ShiftRule } from '../types';\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n"]}
1
+ {"version":3,"sources":["../../../src/core/algorithms/shifts.ts"],"names":["isValidDate","date","applyShift","rule","day","result","daysToNextMonday"],"mappings":"AAEA,SAASA,EAAYC,CAAAA,CAAqB,CACxC,OAAOA,CAAAA,YAAgB,IAAA,EAAQ,OAAO,QAAA,CAASA,CAAAA,CAAK,OAAA,EAAS,CAC/D,CAMO,SAASC,EAAWD,CAAAA,CAAYE,CAAAA,CAAmD,CACxF,GAAI,CAACH,CAAAA,CAAYC,CAAI,EACnB,OAAO,CAAE,KAAAA,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAGhC,IAAMG,CAAAA,CAAMH,CAAAA,CAAK,WAAU,CAE3B,GAAIE,IAAS,MAAA,CACX,OAAO,CAAE,IAAA,CAAAF,CAAAA,CAAM,OAAA,CAAS,KAAM,EAGhC,IAAMI,CAAAA,CAAS,IAAI,IAAA,CAAKJ,CAAI,EAE5B,OAAQE,CAAAA,EACN,KAAK,WACL,KAAK,YAAA,CAAc,CAEjB,GAAIC,CAAAA,GAAQ,EACV,OAAO,CAAE,IAAA,CAAAH,CAAAA,CAAM,QAAS,KAAM,CAAA,CAOhC,IAAMK,CAAAA,CAAAA,CAAoB,CAAA,CAAIF,GAAO,CAAA,CACrCC,CAAAA,CAAO,WAAWJ,CAAAA,CAAK,UAAA,GAAeK,CAAgB,CAAA,CACtD,KACF,CAEA,KAAK,aAEH,GAAIF,CAAAA,GAAQ,CAAA,CAEVC,CAAAA,CAAO,WAAWJ,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BG,IAAQ,CAAA,CAEjBC,CAAAA,CAAO,UAAA,CAAWJ,CAAAA,CAAK,YAAW,CAAI,CAAC,OAEvC,OAAO,CAAE,KAAAA,CAAAA,CAAM,OAAA,CAAS,KAAM,CAAA,CAEhC,MAEF,KAAK,eAAA,CAIH,GAAIG,CAAAA,GAAQ,CAAA,CAEVC,EAAO,UAAA,CAAWJ,CAAAA,CAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BG,CAAAA,GAAQ,EAEjBC,CAAAA,CAAO,UAAA,CAAWJ,EAAK,UAAA,EAAW,CAAI,CAAC,CAAA,CAAA,KAAA,GAC9BG,IAAQ,CAAA,CAEjBC,CAAAA,CAAO,WAAWJ,CAAAA,CAAK,UAAA,GAAe,CAAC,CAAA,CAAA,KAAA,GAC9BG,CAAAA,GAAQ,CAAA,CAEjBC,EAAO,UAAA,CAAWJ,CAAAA,CAAK,YAAW,CAAI,CAAC,OAEvC,OAAO,CAAE,IAAA,CAAAA,CAAAA,CAAM,QAAS,KAAM,CAAA,CAEhC,MAEF,QACE,OAAO,CAAE,IAAA,CAAAA,CAAAA,CAAM,QAAS,KAAM,CAClC,CAEA,OAAO,CAAE,KAAMI,CAAAA,CAAQ,OAAA,CAAS,IAAK,CACvC","file":"shifts.js","sourcesContent":["import type { ShiftRule } from '../types';\n\nfunction isValidDate(date: Date): boolean {\n return date instanceof Date && Number.isFinite(date.getTime());\n}\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n if (!isValidDate(date)) {\n return { date, shifted: false };\n }\n\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';function y(t){let n=t%19,o=Math.floor(t/100),e=t%100,a=Math.floor(o/4),s=o%4,i=Math.floor((o+8)/25),r=Math.floor((o-i+1)/3),l=(19*n+o-a-r+15)%30,C=Math.floor(e/4),U=e%4,c=(32+2*s+2*C-l-U)%7,d=Math.floor((n+11*l+22*c)/451),g=Math.floor((l+c-7*d+114)/31),p=(l+c-7*d+114)%31+1;return new Date(Date.UTC(t,g-1,p))}function h(t,n,o,e){if(e>0){let s=new Date(Date.UTC(t,n-1,1)).getUTCDay(),r=1+(o-s+7)%7+(e-1)*7;return new Date(Date.UTC(t,n-1,r))}else {let a=new Date(Date.UTC(t,n,0)),i=(a.getUTCDay()-o+7)%7,r=a.getUTCDate()-i+(e+1)*7;return new Date(Date.UTC(t,n-1,r))}}function T(t,n){let o=t.getUTCDay();if(n==="none")return {date:t,shifted:false};let e=new Date(t);switch(n){case "emiliani":case "nextMonday":{if(o===1)return {date:t,shifted:false};let a=(8-o)%7;e.setUTCDate(t.getUTCDate()+a);break}case "observedUS":if(o===0)e.setUTCDate(t.getUTCDate()+1);else if(o===6)e.setUTCDate(t.getUTCDate()-1);else return {date:t,shifted:false};break;case "nearestMonday":if(o===2)e.setUTCDate(t.getUTCDate()-1);else if(o===3)e.setUTCDate(t.getUTCDate()-2);else if(o===4)e.setUTCDate(t.getUTCDate()+4);else if(o===5)e.setUTCDate(t.getUTCDate()+3);else return {date:t,shifted:false};break;default:return {date:t,shifted:false}}return {date:e,shifted:true}}function m(t,n){switch(t.type){case "fixed":return new Date(Date.UTC(n,t.month-1,t.day));case "nthWeekday":return h(n,t.month,t.weekday,t.n);case "easterRelative":{let o=y(n),e=new Date(o);return e.setUTCDate(o.getUTCDate()+t.offset),e}case "custom":return t.calc(n)}}function D(t){try{return t.toISOString().split("T")[0]}catch{return ""}}function f(t){return t instanceof Date&&!isNaN(t.getTime())}function u(t,n,o={}){return typeof n!="number"||isNaN(n)?[]:t.map(e=>{let a=m(e.rule,n);if(!a||!f(a))return null;let{date:s,shifted:i}=T(a,e.shift??"none");return f(s)?{date:D(s),key:e.key,name:o[e.key]??e.key,...i&&{isShifted:true}}:null}).filter(e=>e!==null).sort((e,a)=>e.date.localeCompare(a.date))}function M(t,n,o){if(!f(n))return null;let e=n.getUTCFullYear(),a=D(n);return a?u(t,e,o).find(i=>i.date===a)??null:null}function R(t,n,o){if(!f(n))return null;let e=D(n);if(!e)return null;let a=n.getUTCFullYear(),s=u(t,a,o),i=s.find(r=>r.date>=e);return i||(s=u(t,a+1,o),i=s[0]),i??null}exports.checkIsHoliday=M;exports.findNextHoliday=R;exports.resolveHolidays=u;//# sourceMappingURL=engine.cjs.map
1
+ 'use strict';function y(e){if(!Number.isInteger(e)||e<1583)return new Date(Number.NaN);let n=e%19,r=Math.floor(e/100),t=e%100,s=Math.floor(r/4),i=r%4,o=Math.floor((r+8)/25),u=Math.floor((r-o+1)/3),a=(19*n+r-s-u+15)%30,l=Math.floor(t/4),m=t%4,c=(32+2*i+2*l-a-m)%7,g=Math.floor((n+11*a+22*c)/451),C=Math.floor((a+c-7*g+114)/31),U=(a+c-7*g+114)%31+1;return new Date(Date.UTC(e,C-1,U))}function T(e,n,r,t){if(!Number.isInteger(e)||!Number.isInteger(n)||n<1||n>12||!Number.isInteger(r)||r<0||r>6||!Number.isInteger(t)||t===0)return new Date(Number.NaN);let s=n-1;if(t>0){let o=new Date(Date.UTC(e,n-1,1)).getUTCDay(),a=1+(r-o+7)%7+(t-1)*7,l=new Date(Date.UTC(e,n-1,a));return l.getUTCMonth()===s?l:new Date(Number.NaN)}else {let i=new Date(Date.UTC(e,n,0)),u=(i.getUTCDay()-r+7)%7,a=i.getUTCDate()-u+(t+1)*7,l=new Date(Date.UTC(e,n-1,a));return l.getUTCMonth()===s?l:new Date(Number.NaN)}}function b(e){return e instanceof Date&&Number.isFinite(e.getTime())}function h(e,n){if(!b(e))return {date:e,shifted:false};let r=e.getUTCDay();if(n==="none")return {date:e,shifted:false};let t=new Date(e);switch(n){case "emiliani":case "nextMonday":{if(r===1)return {date:e,shifted:false};let s=(8-r)%7;t.setUTCDate(e.getUTCDate()+s);break}case "observedUS":if(r===0)t.setUTCDate(e.getUTCDate()+1);else if(r===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(r===2)t.setUTCDate(e.getUTCDate()-1);else if(r===3)t.setUTCDate(e.getUTCDate()-2);else if(r===4)t.setUTCDate(e.getUTCDate()+4);else if(r===5)t.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:t,shifted:true}}function N(e,n){switch(e.type){case "fixed":return new Date(Date.UTC(n,e.month-1,e.day));case "nthWeekday":return T(n,e.month,e.weekday,e.n);case "easterRelative":{let r=y(n),t=new Date(r);return t.setUTCDate(r.getUTCDate()+e.offset),t}case "custom":return e.calc(n)}}function d(e){try{return e.toISOString().split("T")[0]}catch{return ""}}function f(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function D(e,n,r={}){return typeof n!="number"||!Number.isInteger(n)?[]:e.map(t=>{let s=N(t.rule,n);if(!s||!f(s))return null;let{date:i,shifted:o}=h(s,t.shift??"none");return f(i)?{date:d(i),key:t.key,name:r[t.key]??t.key,...o&&{isShifted:true}}:null}).filter(t=>t!==null).sort((t,s)=>t.date.localeCompare(s.date))}function S(e,n,r){if(!f(n))return null;let t=n.getUTCFullYear(),s=d(n);return s?D(e,t,r).find(o=>o.date===s)??null:null}function I(e,n,r){if(!f(n))return null;let t=d(n);if(!t)return null;let s=n.getUTCFullYear(),i=D(e,s,r),o=i.find(u=>u.date>=t);return o||(i=D(e,s+1,r),o=i[0]),o??null}exports.checkIsHoliday=S;exports.findNextHoliday=I;exports.resolveHolidays=D;//# sourceMappingURL=engine.cjs.map
2
2
  //# sourceMappingURL=engine.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/algorithms/easter.ts","../../src/core/algorithms/nth-weekday.ts","../../src/core/algorithms/shifts.ts","../../src/core/engine.ts"],"names":["getEasterSunday","year","a","b","c","d","e","f","g","h","i","k","l","m","month","day","getNthWeekday","weekday","n","firstWeekday","last","diff","applyShift","date","rule","result","daysToNextMonday","resolveRule","easter","toISODate","isValidDate","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next"],"mappings":"aAIO,SAASA,EAAgBC,CAAAA,CAAoB,CAClD,IAA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C,CAAK,CAAA,CACnDU,EAAOD,CAAAA,CAAS,IAAA,CAAMjC,CAAAA,EAAMA,CAAAA,CAAE,MAAQgC,CAAO,CAAA,CAGjD,OAAKE,CAAAA,GACHD,EAAWX,CAAAA,CAAgBC,CAAAA,CAAa/B,CAAAA,CAAO,CAAA,CAAGgC,CAAK,CAAA,CACvDU,CAAAA,CAAOD,EAAS,CAAC,CAAA,CAAA,CAGZC,GAAQ,IACjB","file":"engine.cjs","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n","/**\n * Calculates the Nth weekday of a month\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n return new Date(Date.UTC(year, month - 1, day));\n }\n}\n","import type { ShiftRule } from '../types';\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n","import type { HolidayDefinition, HolidayRule, Holiday } from './types';\nimport { getEasterSunday } from './algorithms/easter';\nimport { getNthWeekday } from './algorithms/nth-weekday';\nimport { applyShift } from './algorithms/shifts';\n\n/** Resolves a rule to a concrete date */\nfunction resolveRule(rule: HolidayRule, year: number): Date | null {\n switch (rule.type) {\n case 'fixed':\n return new Date(Date.UTC(year, rule.month - 1, rule.day));\n\n case 'nthWeekday':\n return getNthWeekday(year, rule.month, rule.weekday, rule.n);\n\n case 'easterRelative': {\n const easter = getEasterSunday(year);\n const result = new Date(easter);\n result.setUTCDate(easter.getUTCDate() + rule.offset);\n return result;\n }\n\n case 'custom':\n return rule.calc(year);\n }\n}\n\n/** Formats Date to ISO string (date only) */\nfunction toISODate(date: Date): string {\n try {\n return date.toISOString().split('T')[0];\n } catch {\n return '';\n }\n}\n\n/** Checks if a date is valid */\nfunction isValidDate(date: Date): boolean {\n return date instanceof Date && !isNaN(date.getTime());\n}\n\n/** Generates holidays for a year */\nexport function resolveHolidays(\n definitions: HolidayDefinition[],\n year: number,\n names: Record<string, string> = {},\n): Holiday[] {\n if (typeof year !== 'number' || isNaN(year)) {\n return [];\n }\n\n return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate || !isValidDate(rawDate)) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\n if (!isValidDate(date)) return null;\n\n return {\n date: toISODate(date),\n key: def.key,\n name: names[def.key] ?? def.key,\n ...(shifted && { isShifted: true }),\n };\n })\n .filter((h): h is Holiday => h !== null)\n .sort((a, b) => a.date.localeCompare(b.date));\n}\n\n/** Checks if a date is a holiday */\nexport function checkIsHoliday(\n definitions: HolidayDefinition[],\n date: Date,\n names?: Record<string, string>,\n): Holiday | null {\n if (!isValidDate(date)) return null;\n\n const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\n if (!isoDate) return null;\n\n const holidays = resolveHolidays(definitions, year, names);\n return holidays.find((h) => h.date === isoDate) ?? null;\n}\n\n/** Gets the next holiday from a date */\nexport function findNextHoliday(\n definitions: HolidayDefinition[],\n from: Date,\n names?: Record<string, string>,\n): Holiday | null {\n if (!isValidDate(from)) return null;\n\n const isoFrom = toISODate(from);\n if (!isoFrom) return null;\n\n const year = from.getUTCFullYear();\n\n // Search in current year\n let holidays = resolveHolidays(definitions, year, names);\n let next = holidays.find((h) => h.date >= isoFrom);\n\n // If none, search in next year\n if (!next) {\n holidays = resolveHolidays(definitions, year + 1, names);\n next = holidays[0];\n }\n\n return next ?? null;\n}\n"]}
1
+ {"version":3,"sources":["../../src/core/algorithms/easter.ts","../../src/core/algorithms/nth-weekday.ts","../../src/core/algorithms/shifts.ts","../../src/core/engine.ts"],"names":["getEasterSunday","year","a","b","c","d","e","f","g","h","i","k","l","m","month","day","getNthWeekday","weekday","n","expectedMonth","firstWeekday","result","last","diff","isValidDate","date","applyShift","rule","daysToNextMonday","resolveRule","easter","toISODate","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next"],"mappings":"aAIO,SAASA,EAAgBC,CAAAA,CAAoB,CAClD,GAAI,CAAC,MAAA,CAAO,UAAUA,CAAI,CAAA,EAAKA,EAAO,IAAA,CACpC,OAAO,IAAI,IAAA,CAAK,MAAA,CAAO,GAAG,CAAA,CAG5B,IAAMC,EAAID,CAAAA,CAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,MAAMF,CAAAA,CAAO,GAAG,EACzBG,CAAAA,CAAIH,CAAAA,CAAO,IACXI,CAAAA,CAAI,IAAA,CAAK,MAAMF,CAAAA,CAAI,CAAC,EACpBG,CAAAA,CAAIH,CAAAA,CAAI,EACRI,CAAAA,CAAI,IAAA,CAAK,OAAOJ,CAAAA,CAAI,CAAA,EAAK,EAAE,CAAA,CAC3BK,EAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,EAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,CAAAA,CAAAA,CAAK,GAAKP,CAAAA,CAAIC,CAAAA,CAAIE,EAAIG,C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AAS,OAAO,KAErB,IAAMzC,CAAAA,CAAOwC,EAAK,cAAA,EAAe,CAG7BE,EAAWX,CAAAA,CAAgBC,CAAAA,CAAahC,EAAMiC,CAAK,CAAA,CACnDU,EAAOD,CAAAA,CAAS,IAAA,CAAMlC,GAAMA,CAAAA,CAAE,IAAA,EAAQiC,CAAO,CAAA,CAGjD,OAAKE,IACHD,CAAAA,CAAWX,CAAAA,CAAgBC,EAAahC,CAAAA,CAAO,CAAA,CAAGiC,CAAK,CAAA,CACvDU,CAAAA,CAAOD,EAAS,CAAC,CAAA,CAAA,CAGZC,GAAQ,IACjB","file":"engine.cjs","sourcesContent":["/**\n * Calculates Easter Sunday (Meeus/Jones/Butcher algorithm)\n * Valid for Gregorian calendar (1583+)\n */\nexport function getEasterSunday(year: number): Date {\n if (!Number.isInteger(year) || year < 1583) {\n return new Date(Number.NaN);\n }\n\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n\n return new Date(Date.UTC(year, month - 1, day));\n}\n","/**\n * Calculates the Nth weekday of a month\n * @param year - Year\n * @param month - Month (1-12)\n * @param weekday - Weekday (0=Sun, 1=Mon, ..., 6=Sat)\n * @param n - Occurrence (1=first, 2=second, -1=last)\n */\nexport function getNthWeekday(year: number, month: number, weekday: number, n: number): Date {\n if (\n !Number.isInteger(year) ||\n !Number.isInteger(month) ||\n month < 1 ||\n month > 12 ||\n !Number.isInteger(weekday) ||\n weekday < 0 ||\n weekday > 6 ||\n !Number.isInteger(n) ||\n n === 0\n ) {\n return new Date(Number.NaN);\n }\n\n const expectedMonth = month - 1;\n\n if (n > 0) {\n // From start of month\n const first = new Date(Date.UTC(year, month - 1, 1));\n const firstWeekday = first.getUTCDay();\n const diff = (weekday - firstWeekday + 7) % 7;\n const day = 1 + diff + (n - 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n } else {\n // From end of month (n = -1 = last)\n // month is 1-12. Date.UTC(year, month, 0) gives the last day of month 'month'\n const last = new Date(Date.UTC(year, month, 0));\n const lastWeekday = last.getUTCDay();\n const diff = (lastWeekday - weekday + 7) % 7;\n const day = last.getUTCDate() - diff + (n + 1) * 7;\n const result = new Date(Date.UTC(year, month - 1, day));\n return result.getUTCMonth() === expectedMonth ? result : new Date(Number.NaN);\n }\n}\n","import type { ShiftRule } from '../types';\n\nfunction isValidDate(date: Date): boolean {\n return date instanceof Date && Number.isFinite(date.getTime());\n}\n\n/**\n * Applies a shift rule to a date\n * @returns { date: Date, shifted: boolean }\n */\nexport function applyShift(date: Date, rule: ShiftRule): { date: Date; shifted: boolean } {\n if (!isValidDate(date)) {\n return { date, shifted: false };\n }\n\n const day = date.getUTCDay(); // 0=Sun, 6=Sat\n\n if (rule === 'none') {\n return { date, shifted: false };\n }\n\n const result = new Date(date);\n\n switch (rule) {\n case 'emiliani':\n case 'nextMonday': {\n // If it's already Monday (1), do not move\n if (day === 1) {\n return { date, shifted: false };\n }\n // Move to next Monday\n // (8 - day) % 7 gives days until next Monday\n // Ex: Sun(0) -> (8-0)%7 = 1 (+1 day) -> Mon\n // Ex: Sat(6) -> (8-6)%7 = 2 (+2 days) -> Mon\n // Ex: Wed(3) -> (8-3)%7 = 5 (+5 days) -> Mon\n const daysToNextMonday = (8 - day) % 7;\n result.setUTCDate(date.getUTCDate() + daysToNextMonday);\n break;\n }\n\n case 'observedUS':\n // Only affects weekends\n if (day === 0) {\n // Sunday -> Monday (+1)\n result.setUTCDate(date.getUTCDate() + 1);\n } else if (day === 6) {\n // Saturday -> Friday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else {\n return { date, shifted: false };\n }\n break;\n\n case 'nearestMonday':\n // Argentina rule:\n // Tue/Wed -> Previous Monday\n // Thu/Fri -> Next Monday\n if (day === 2) {\n // Tuesday -> Monday (-1)\n result.setUTCDate(date.getUTCDate() - 1);\n } else if (day === 3) {\n // Wednesday -> Monday (-2)\n result.setUTCDate(date.getUTCDate() - 2);\n } else if (day === 4) {\n // Thursday -> Next Monday (+4)\n result.setUTCDate(date.getUTCDate() + 4);\n } else if (day === 5) {\n // Friday -> Next Monday (+3)\n result.setUTCDate(date.getUTCDate() + 3);\n } else {\n return { date, shifted: false };\n }\n break;\n\n default:\n return { date, shifted: false };\n }\n\n return { date: result, shifted: true };\n}\n","import type { HolidayDefinition, HolidayRule, Holiday } from './types';\nimport { getEasterSunday } from './algorithms/easter';\nimport { getNthWeekday } from './algorithms/nth-weekday';\nimport { applyShift } from './algorithms/shifts';\n\n/** Resolves a rule to a concrete date */\nfunction resolveRule(rule: HolidayRule, year: number): Date | null {\n switch (rule.type) {\n case 'fixed':\n return new Date(Date.UTC(year, rule.month - 1, rule.day));\n\n case 'nthWeekday':\n return getNthWeekday(year, rule.month, rule.weekday, rule.n);\n\n case 'easterRelative': {\n const easter = getEasterSunday(year);\n const result = new Date(easter);\n result.setUTCDate(easter.getUTCDate() + rule.offset);\n return result;\n }\n\n case 'custom':\n return rule.calc(year);\n }\n}\n\n/** Formats Date to ISO string (date only) */\nfunction toISODate(date: Date): string {\n try {\n return date.toISOString().split('T')[0];\n } catch {\n return '';\n }\n}\n\n/** Checks if a date is valid */\nfunction isValidDate(date: Date): boolean {\n return date instanceof Date && !Number.isNaN(date.getTime());\n}\n\n/** Generates holidays for a year */\nexport function resolveHolidays(\n definitions: HolidayDefinition[],\n year: number,\n names: Record<string, string> = {},\n): Holiday[] {\n if (typeof year !== 'number' || !Number.isInteger(year)) {\n return [];\n }\n\n return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate || !isValidDate(rawDate)) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\n if (!isValidDate(date)) return null;\n\n return {\n date: toISODate(date),\n key: def.key,\n name: names[def.key] ?? def.key,\n ...(shifted && { isShifted: true }),\n };\n })\n .filter((h): h is Holiday => h !== null)\n .sort((a, b) => a.date.localeCompare(b.date));\n}\n\n/** Checks if a date is a holiday */\nexport function checkIsHoliday(\n definitions: HolidayDefinition[],\n date: Date,\n names?: Record<string, string>,\n): Holiday | null {\n if (!isValidDate(date)) return null;\n\n const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\n if (!isoDate) return null;\n\n const holidays = resolveHolidays(definitions, year, names);\n return holidays.find((h) => h.date === isoDate) ?? null;\n}\n\n/** Gets the next holiday from a date */\nexport function findNextHoliday(\n definitions: HolidayDefinition[],\n from: Date,\n names?: Record<string, string>,\n): Holiday | null {\n if (!isValidDate(from)) return null;\n\n const isoFrom = toISODate(from);\n if (!isoFrom) return null;\n\n const year = from.getUTCFullYear();\n\n // Search in current year\n let holidays = resolveHolidays(definitions, year, names);\n let next = holidays.find((h) => h.date >= isoFrom);\n\n // If none, search in next year\n if (!next) {\n holidays = resolveHolidays(definitions, year + 1, names);\n next = holidays[0];\n }\n\n return next ?? null;\n}\n"]}
@@ -1,2 +1,2 @@
1
- function y(t){let n=t%19,o=Math.floor(t/100),e=t%100,a=Math.floor(o/4),s=o%4,i=Math.floor((o+8)/25),r=Math.floor((o-i+1)/3),l=(19*n+o-a-r+15)%30,C=Math.floor(e/4),U=e%4,c=(32+2*s+2*C-l-U)%7,d=Math.floor((n+11*l+22*c)/451),g=Math.floor((l+c-7*d+114)/31),p=(l+c-7*d+114)%31+1;return new Date(Date.UTC(t,g-1,p))}function h(t,n,o,e){if(e>0){let s=new Date(Date.UTC(t,n-1,1)).getUTCDay(),r=1+(o-s+7)%7+(e-1)*7;return new Date(Date.UTC(t,n-1,r))}else {let a=new Date(Date.UTC(t,n,0)),i=(a.getUTCDay()-o+7)%7,r=a.getUTCDate()-i+(e+1)*7;return new Date(Date.UTC(t,n-1,r))}}function T(t,n){let o=t.getUTCDay();if(n==="none")return {date:t,shifted:false};let e=new Date(t);switch(n){case "emiliani":case "nextMonday":{if(o===1)return {date:t,shifted:false};let a=(8-o)%7;e.setUTCDate(t.getUTCDate()+a);break}case "observedUS":if(o===0)e.setUTCDate(t.getUTCDate()+1);else if(o===6)e.setUTCDate(t.getUTCDate()-1);else return {date:t,shifted:false};break;case "nearestMonday":if(o===2)e.setUTCDate(t.getUTCDate()-1);else if(o===3)e.setUTCDate(t.getUTCDate()-2);else if(o===4)e.setUTCDate(t.getUTCDate()+4);else if(o===5)e.setUTCDate(t.getUTCDate()+3);else return {date:t,shifted:false};break;default:return {date:t,shifted:false}}return {date:e,shifted:true}}function m(t,n){switch(t.type){case "fixed":return new Date(Date.UTC(n,t.month-1,t.day));case "nthWeekday":return h(n,t.month,t.weekday,t.n);case "easterRelative":{let o=y(n),e=new Date(o);return e.setUTCDate(o.getUTCDate()+t.offset),e}case "custom":return t.calc(n)}}function D(t){try{return t.toISOString().split("T")[0]}catch{return ""}}function f(t){return t instanceof Date&&!isNaN(t.getTime())}function u(t,n,o={}){return typeof n!="number"||isNaN(n)?[]:t.map(e=>{let a=m(e.rule,n);if(!a||!f(a))return null;let{date:s,shifted:i}=T(a,e.shift??"none");return f(s)?{date:D(s),key:e.key,name:o[e.key]??e.key,...i&&{isShifted:true}}:null}).filter(e=>e!==null).sort((e,a)=>e.date.localeCompare(a.date))}function M(t,n,o){if(!f(n))return null;let e=n.getUTCFullYear(),a=D(n);return a?u(t,e,o).find(i=>i.date===a)??null:null}function R(t,n,o){if(!f(n))return null;let e=D(n);if(!e)return null;let a=n.getUTCFullYear(),s=u(t,a,o),i=s.find(r=>r.date>=e);return i||(s=u(t,a+1,o),i=s[0]),i??null}export{M as checkIsHoliday,R as findNextHoliday,u as resolveHolidays};//# sourceMappingURL=engine.js.map
1
+ function y(e){if(!Number.isInteger(e)||e<1583)return new Date(Number.NaN);let n=e%19,r=Math.floor(e/100),t=e%100,s=Math.floor(r/4),i=r%4,o=Math.floor((r+8)/25),u=Math.floor((r-o+1)/3),a=(19*n+r-s-u+15)%30,l=Math.floor(t/4),m=t%4,c=(32+2*i+2*l-a-m)%7,g=Math.floor((n+11*a+22*c)/451),C=Math.floor((a+c-7*g+114)/31),U=(a+c-7*g+114)%31+1;return new Date(Date.UTC(e,C-1,U))}function T(e,n,r,t){if(!Number.isInteger(e)||!Number.isInteger(n)||n<1||n>12||!Number.isInteger(r)||r<0||r>6||!Number.isInteger(t)||t===0)return new Date(Number.NaN);let s=n-1;if(t>0){let o=new Date(Date.UTC(e,n-1,1)).getUTCDay(),a=1+(r-o+7)%7+(t-1)*7,l=new Date(Date.UTC(e,n-1,a));return l.getUTCMonth()===s?l:new Date(Number.NaN)}else {let i=new Date(Date.UTC(e,n,0)),u=(i.getUTCDay()-r+7)%7,a=i.getUTCDate()-u+(t+1)*7,l=new Date(Date.UTC(e,n-1,a));return l.getUTCMonth()===s?l:new Date(Number.NaN)}}function b(e){return e instanceof Date&&Number.isFinite(e.getTime())}function h(e,n){if(!b(e))return {date:e,shifted:false};let r=e.getUTCDay();if(n==="none")return {date:e,shifted:false};let t=new Date(e);switch(n){case "emiliani":case "nextMonday":{if(r===1)return {date:e,shifted:false};let s=(8-r)%7;t.setUTCDate(e.getUTCDate()+s);break}case "observedUS":if(r===0)t.setUTCDate(e.getUTCDate()+1);else if(r===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(r===2)t.setUTCDate(e.getUTCDate()-1);else if(r===3)t.setUTCDate(e.getUTCDate()-2);else if(r===4)t.setUTCDate(e.getUTCDate()+4);else if(r===5)t.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:t,shifted:true}}function N(e,n){switch(e.type){case "fixed":return new Date(Date.UTC(n,e.month-1,e.day));case "nthWeekday":return T(n,e.month,e.weekday,e.n);case "easterRelative":{let r=y(n),t=new Date(r);return t.setUTCDate(r.getUTCDate()+e.offset),t}case "custom":return e.calc(n)}}function d(e){try{return e.toISOString().split("T")[0]}catch{return ""}}function f(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function D(e,n,r={}){return typeof n!="number"||!Number.isInteger(n)?[]:e.map(t=>{let s=N(t.rule,n);if(!s||!f(s))return null;let{date:i,shifted:o}=h(s,t.shift??"none");return f(i)?{date:d(i),key:t.key,name:r[t.key]??t.key,...o&&{isShifted:true}}:null}).filter(t=>t!==null).sort((t,s)=>t.date.localeCompare(s.date))}function S(e,n,r){if(!f(n))return null;let t=n.getUTCFullYear(),s=d(n);return s?D(e,t,r).find(o=>o.date===s)??null:null}function I(e,n,r){if(!f(n))return null;let t=d(n);if(!t)return null;let s=n.getUTCFullYear(),i=D(e,s,r),o=i.find(u=>u.date>=t);return o||(i=D(e,s+1,r),o=i[0]),o??null}export{S as checkIsHoliday,I as findNextHoliday,D as resolveHolidays};//# sourceMappingURL=engine.js.map
2
2
  //# sourceMappingURL=engine.js.map