soff-date 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,10 @@
1
- # Soff Date
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/bledxs/soff-monorepo/master/assets/logo.png" alt="Soff Logo" width="100" height="100">
3
+ <h1>Soff Date</h1>
4
+ <p>Lightweight, tree-shakeable holiday calculator with algorithmic date computation.</p>
5
+ </div>
6
+
7
+ <div align="center">
2
8
 
3
9
  [![npm](https://img.shields.io/npm/v/soff-date)](https://www.npmjs.com/package/soff-date)
4
10
  [![License](https://img.shields.io/github/license/bledxs/soff-monorepo)](LICENSE)
@@ -7,74 +13,90 @@
7
13
  [![minzipped size](https://img.shields.io/bundlephobia/minzip/soff-date)](https://bundlephobia.com/package/soff-date)
8
14
  [![All Contributors](https://img.shields.io/github/all-contributors/bledxs/soff-monorepo?color=ee8449&style=flat-square)](#contributors)
9
15
 
10
- Lightweight, tree-shakeable holiday calculator with algorithmic date computation.
16
+ </div>
17
+
18
+ ---
11
19
 
12
20
  **Zero dependencies** · **TypeScript** · **~3KB per locale**
13
21
 
14
22
  ## Table of Contents
15
23
 
16
- - [Soff Date](#soff-date)
17
- - [Table of Contents](#table-of-contents)
18
- - [Why?](#why)
19
- - [Install](#install)
20
- - [Quick Start](#quick-start)
21
- - [i18n Support](#i18n-support)
22
- - [Available Locales](#available-locales)
23
- - [Available Languages](#available-languages)
24
- - [Shift Rules Explained](#shift-rules-explained)
25
- - [Emiliani (Colombia, Argentina)](#emiliani-colombia-argentina)
26
- - [Observed US (USA, UK)](#observed-us-usa-uk)
27
- - [Advanced: Create Your Own Locale](#advanced-create-your-own-locale)
28
- - [Advanced: Use Algorithms Directly](#advanced-use-algorithms-directly)
29
- - [Bundle Size](#bundle-size)
30
- - [API Reference](#api-reference)
31
- - [`getHolidays(year, options?)`](#getholidaysyear-options)
32
- - [`isHoliday(date, options?)`](#isholidaydate-options)
33
- - [`getNextHoliday(from?, options?)`](#getnextholidayfrom-options)
34
- - [Types](#types)
35
- - [Contributing](#contributing)
36
- - [License](#license)
37
- - [Documentation](#documentation)
38
- - [Contributors](#contributors)
39
-
40
- ## Why?
41
-
42
- Most holiday libraries ship giant JSON files with dates until 2050. This library **calculates dates algorithmically**, supporting:
43
-
44
- - Fixed dates (`December 25`)
45
- - Nth weekday (`3rd Monday of January`)
46
- - Easter-relative (`Good Friday = Easter - 2 days`)
47
- - Shift rules (`Emiliani`, `Observed US`)
48
-
49
- ## Install
24
+ - [Table of Contents](#table-of-contents)
25
+ - [🤔 Why?](#-why)
26
+ - [📦 Install](#-install)
27
+ - [🚀 Quick Start](#-quick-start)
28
+ - [🌍 i18n Support](#-i18n-support)
29
+ - [Available Locales](#available-locales)
30
+ - [Available Languages](#available-languages)
31
+ - [Shift Rules Explained](#shift-rules-explained)
32
+ - [Emiliani (Colombia, Argentina)](#emiliani-colombia-argentina)
33
+ - [Observed US (USA, UK)](#observed-us-usa-uk)
34
+ - [Advanced: Create Your Own Locale](#advanced-create-your-own-locale)
35
+ - [Advanced: Use Algorithms Directly](#advanced-use-algorithms-directly)
36
+ - [Bundle Size](#bundle-size)
37
+ - [API Reference](#api-reference)
38
+ - [`getHolidays(year, options?)`](#getholidaysyear-options)
39
+ - [`isHoliday(date, options?)`](#isholidaydate-options)
40
+ - [`getNextHoliday(from?, options?)`](#getnextholidayfrom-options)
41
+ - [Business Days Calculation](#business-days-calculation)
42
+ - [Types](#types)
43
+ - [Contributing](#contributing)
44
+ - [License](#license)
45
+ - [Documentation](#documentation)
46
+ - [Contributors](#contributors)
47
+
48
+ ## 🤔 Why?
49
+
50
+ Most holiday libraries ship **giant JSON files** with dates until 2050. This library **calculates dates algorithmically**, supporting:
51
+
52
+ | Feature | Description | Example |
53
+ | ---------------------- | ----------------------------- | ------------------------------- |
54
+ | 📅 **Fixed Dates** | Static dates every year | December 25 (Christmas) |
55
+ | 📆 **Nth Weekday** | Relative weekday calculations | 3rd Monday of January (MLK Day) |
56
+ | ✨ **Easter-relative** | Based on Easter calculation | Good Friday = Easter - 2 days |
57
+ | 🔄 **Shift Rules** | Move holidays to workdays | Colombia's Emiliani Law |
58
+
59
+ **Result:** Tiny bundle size (~3KB) with unlimited year support! 🎉
60
+
61
+ ## 📦 Install
50
62
 
51
63
  ```bash
64
+ # npm
52
65
  npm install soff-date
66
+
67
+ # pnpm
68
+ pnpm add soff-date
69
+
70
+ # yarn
71
+ yarn add soff-date
72
+
73
+ # bun
74
+ bun add soff-date
53
75
  ```
54
76
 
55
- ## Quick Start
77
+ ## 🚀 Quick Start
56
78
 
57
79
  ```typescript
58
80
  // Only Colombia included in bundle (~3KB)
59
81
  import { getHolidays, isHoliday, getNextHoliday } from 'soff-date/locales/co';
60
82
 
61
- // Get all holidays for a year
83
+ // 🏆 Get all holidays for a year
62
84
  getHolidays(2025);
63
85
  // → [{ date: '2025-01-01', key: 'newYear', name: 'Año Nuevo' }, ...]
64
86
 
65
- // Check if a date is a holiday
87
+ // Check if a date is a holiday
66
88
  isHoliday(new Date('2025-01-01'));
67
89
  // → { date: '2025-01-01', key: 'newYear', name: 'Año Nuevo' }
68
90
 
69
91
  isHoliday(new Date('2025-01-02'));
70
92
  // → null
71
93
 
72
- // Get next holiday from a date
94
+ // ➡️ Get next holiday from a date
73
95
  getNextHoliday(new Date('2025-01-02'));
74
96
  // → { date: '2025-01-06', key: 'epiphany', name: 'Día de los Reyes Magos' }
75
97
  ```
76
98
 
77
- ## i18n Support
99
+ ## 🌍 i18n Support
78
100
 
79
101
  ```typescript
80
102
  import { getHolidays } from 'soff-date/locales/co';
@@ -191,11 +213,11 @@ applyShift(new Date('2026-07-04'), 'observedUS');
191
213
 
192
214
  | Import | Size (minified) |
193
215
  | ------------ | --------------- |
194
- | `locales/co` | ~4.3KB |
195
- | `locales/us` | ~3.7KB |
196
- | `i18n/es` | ~1.2KB |
216
+ | `locales/co` | ~5.8KB |
217
+ | `locales/us` | ~4.5KB |
218
+ | `i18n/es` | ~1.9KB |
197
219
  | `i18n/en` | ~1.1KB |
198
- | Core only | ~1.9KB |
220
+ | Core only | ~2.7KB |
199
221
 
200
222
  Tree-shaking ensures you only ship what you import.
201
223
 
@@ -228,6 +250,27 @@ Returns holiday info if the date is a holiday, `null` otherwise.
228
250
 
229
251
  Returns the next holiday from a given date (defaults to today).
230
252
 
253
+ ## Business Days Calculation
254
+
255
+ In addition to holiday calculation, `soff-date` provides utilities to work with business days (skipping weekends and holidays).
256
+
257
+ ```typescript
258
+ import { isBusinessDay, businessDays, diffBusinessDays } from 'soff-date/locales/co';
259
+
260
+ // Check if a date is a business day
261
+ isBusinessDay(new Date('2025-01-01')); // false (Holiday)
262
+ isBusinessDay(new Date('2025-01-04')); // false (Saturday)
263
+ isBusinessDay(new Date('2025-01-02')); // true
264
+
265
+ // Add business days
266
+ businessDays(new Date('2025-01-03'), 1);
267
+ // → Date('2025-01-06') (Friday + 1 business day = Monday)
268
+
269
+ // Calculate difference in business days
270
+ diffBusinessDays(new Date('2025-01-06'), new Date('2025-01-10'));
271
+ // → 4
272
+ ```
273
+
231
274
  ## Types
232
275
 
233
276
  ```typescript
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';function d(e){let o=e%19,n=Math.floor(e/100),t=e%100,a=Math.floor(n/4),s=n%4,i=Math.floor((n+8)/25),r=Math.floor((n-i+1)/3),l=(19*o+n-a-r+15)%30,g=Math.floor(t/4),C=t%4,c=(32+2*s+2*g-l-C)%7,p=Math.floor((o+11*l+22*c)/451),U=Math.floor((l+c-7*p+114)/31),H=(l+c-7*p+114)%31+1;return new Date(Date.UTC(e,U-1,H))}function u(e,o,n,t){if(t>0){let s=new Date(Date.UTC(e,o-1,1)).getUTCDay(),r=1+(n-s+7)%7+(t-1)*7;return new Date(Date.UTC(e,o-1,r))}else {let a=new Date(Date.UTC(e,o,0)),i=(a.getUTCDay()-n+7)%7,r=a.getUTCDate()-i+(t+1)*7;return new Date(Date.UTC(e,o-1,r))}}function y(e,o){let n=e.getUTCDay();if(o==="none")return {date:e,shifted:false};let t=new Date(e);switch(o){case "emiliani":case "nextMonday":{if(n===1)return {date:e,shifted:false};let a=(8-n)%7;t.setUTCDate(e.getUTCDate()+a);break}case "observedUS":if(n===0)t.setUTCDate(e.getUTCDate()+1);else if(n===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(n===2)t.setUTCDate(e.getUTCDate()-1);else if(n===3)t.setUTCDate(e.getUTCDate()-2);else if(n===4)t.setUTCDate(e.getUTCDate()+4);else if(n===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 k(e,o){switch(e.type){case "fixed":return new Date(Date.UTC(o,e.month-1,e.day));case "nthWeekday":return u(o,e.month,e.weekday,e.n);case "easterRelative":{let n=d(o),t=new Date(n);return t.setUTCDate(n.getUTCDate()+e.offset),t}case "custom":return e.calc(o)}}function D(e){return e.toISOString().split("T")[0]}function f(e,o,n={}){return e.map(t=>{let a=k(t.rule,o);if(!a)return null;let{date:s,shifted:i}=y(a,t.shift??"none");return {date:D(s),key:t.key,name:n[t.key]??t.key,...i&&{isShifted:true}}}).filter(t=>t!==null).sort((t,a)=>t.date.localeCompare(a.date))}function h(e,o,n){let t=o.getUTCFullYear(),a=D(o);return f(e,t,n).find(i=>i.date===a)??null}function x(e,o,n){let t=D(o),a=o.getUTCFullYear(),s=f(e,a,n),i=s.find(r=>r.date>=t);return i||(s=f(e,a+1,n),i=s[0]),i??null}function m(e){let o=e.getUTCDay();return o===0||o===6}function T(e,o){return m(o)?false:h(e,o)===null}function b(e,o,n){let t=new Date(o),a=Math.abs(n),s=n>=0?1:-1;for(;a>0;)t.setUTCDate(t.getUTCDate()+s),T(e,t)&&a--;return t}exports.addBusinessDays=b;exports.applyShift=y;exports.checkIsBusinessDay=T;exports.checkIsHoliday=h;exports.findNextHoliday=x;exports.getEasterSunday=d;exports.getNthWeekday=u;exports.isWeekend=m;exports.resolveHolidays=f;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';function u(e){let n=e%19,o=Math.floor(e/100),t=e%100,s=Math.floor(o/4),a=o%4,i=Math.floor((o+8)/25),r=Math.floor((o-i+1)/3),l=(19*n+o-s-r+15)%30,m=Math.floor(t/4),C=t%4,c=(32+2*a+2*m-l-C)%7,T=Math.floor((n+11*l+22*c)/451),U=Math.floor((l+c-7*T+114)/31),H=(l+c-7*T+114)%31+1;return new Date(Date.UTC(e,U-1,H))}function D(e,n,o,t){if(t>0){let a=new Date(Date.UTC(e,n-1,1)).getUTCDay(),r=1+(o-a+7)%7+(t-1)*7;return new Date(Date.UTC(e,n-1,r))}else {let s=new Date(Date.UTC(e,n,0)),i=(s.getUTCDay()-o+7)%7,r=s.getUTCDate()-i+(t+1)*7;return new Date(Date.UTC(e,n-1,r))}}function d(e,n){let o=e.getUTCDay();if(n==="none")return {date:e,shifted:false};let t=new Date(e);switch(n){case "emiliani":case "nextMonday":{if(o===1)return {date:e,shifted:false};let s=(8-o)%7;t.setUTCDate(e.getUTCDate()+s);break}case "observedUS":if(o===0)t.setUTCDate(e.getUTCDate()+1);else if(o===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(o===2)t.setUTCDate(e.getUTCDate()-1);else if(o===3)t.setUTCDate(e.getUTCDate()-2);else if(o===4)t.setUTCDate(e.getUTCDate()+4);else if(o===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 k(e,n){switch(e.type){case "fixed":return new Date(Date.UTC(n,e.month-1,e.day));case "nthWeekday":return D(n,e.month,e.weekday,e.n);case "easterRelative":{let o=u(n),t=new Date(o);return t.setUTCDate(o.getUTCDate()+e.offset),t}case "custom":return e.calc(n)}}function y(e){return e.toISOString().split("T")[0]}function f(e,n,o={}){return e.map(t=>{let s=k(t.rule,n);if(!s)return null;let{date:a,shifted:i}=d(s,t.shift??"none");return {date:y(a),key:t.key,name:o[t.key]??t.key,...i&&{isShifted:true}}}).filter(t=>t!==null).sort((t,s)=>t.date.localeCompare(s.date))}function h(e,n,o){let t=n.getUTCFullYear(),s=y(n);return f(e,t,o).find(i=>i.date===s)??null}function x(e,n,o){let t=y(n),s=n.getUTCFullYear(),a=f(e,s,o),i=a.find(r=>r.date>=t);return i||(a=f(e,s+1,o),i=a[0]),i??null}function g(e){let n=e.getUTCDay();return n===0||n===6}function p(e,n){return g(n)?false:h(e,n)===null}function w(e,n,o){let t=new Date(n),s=Math.abs(o),a=o>=0?1:-1;for(;s>0;)t.setUTCDate(t.getUTCDate()+a),p(e,t)&&s--;return t}function b(e,n,o){let t=new Date(n),s=new Date(o);if(t.setUTCHours(0,0,0,0),s.setUTCHours(0,0,0,0),t.getTime()===s.getTime())return 0;let a=t<s?1:-1,i=0,r=new Date(t);for(;r.getTime()!==s.getTime();)r.setUTCDate(r.getUTCDate()+a),p(e,r)&&(i+=a);return i}exports.addBusinessDays=w;exports.applyShift=d;exports.checkIsBusinessDay=p;exports.checkIsHoliday=h;exports.findNextHoliday=x;exports.getBusinessDaysBetween=b;exports.getEasterSunday=u;exports.getNthWeekday=D;exports.isWeekend=g;exports.resolveHolidays=f;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.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","../src/core/business.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","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction"],"m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,SAASsB,EACdd,CAAAA,CACAe,CAAAA,CACAC,CAAAA,CACM,CACN,IAAMtB,CAAAA,CAAS,IAAI,IAAA,CAAKqB,CAAS,EAC7BE,CAAAA,CAAY,IAAA,CAAK,GAAA,CAAID,CAAM,EACzBE,CAAAA,CAAYF,CAAAA,EAAU,CAAA,CAAI,CAAA,CAAI,GAEpC,KAAOC,CAAAA,CAAY,CAAA,EACjBvB,CAAAA,CAAO,WAAWA,CAAAA,CAAO,UAAA,EAAW,CAAIwB,CAAS,EAC7CL,CAAAA,CAAmBb,CAAAA,CAAaN,CAAM,CAAA,EACxCuB,CAAAA,EAAAA,CAIJ,OAAOvB,CACT","file":"index.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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\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","../src/core/business.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","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction","getBusinessDaysBetween","endDate","start","end","count","current"],"mappings":"aAIO,SAASA,EAAgBC,CAAAA,CAAoB,CAClD,IAAMC,CAAAA,CAAID,CAAAA,CAAO,GACXE,CAAAA,CAA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AAO,UAAA,GAAewB,CAAS,CAAA,CAC7CL,EAAmBb,CAAAA,CAAaN,CAAM,GACxCuB,CAAAA,EAAAA,CAIJ,OAAOvB,CACT,CAOO,SAASyB,EACdnB,CAAAA,CACAe,CAAAA,CACAK,EACQ,CACR,IAAMC,CAAAA,CAAQ,IAAI,KAAKN,CAAS,CAAA,CAC1BO,EAAM,IAAI,IAAA,CAAKF,CAAO,CAAA,CAM5B,GAHAC,EAAM,WAAA,CAAY,CAAA,CAAG,EAAG,CAAA,CAAG,CAAC,EAC5BC,CAAAA,CAAI,WAAA,CAAY,EAAG,CAAA,CAAG,CAAA,CAAG,CAAC,CAAA,CAEtBD,EAAM,OAAA,EAAQ,GAAMC,EAAI,OAAA,EAAQ,CAAG,OAAO,CAAA,CAE9C,IAAMJ,EAAYG,CAAAA,CAAQC,CAAAA,CAAM,EAAI,EAAA,CAChCC,CAAAA,CAAQ,EACNC,CAAAA,CAAU,IAAI,KAAKH,CAAK,CAAA,CAK9B,KAAOG,CAAAA,CAAQ,SAAQ,GAAMF,CAAAA,CAAI,SAAQ,EACvCE,CAAAA,CAAQ,WAAWA,CAAAA,CAAQ,UAAA,GAAeN,CAAS,CAAA,CAC/CL,EAAmBb,CAAAA,CAAawB,CAAO,IACzCD,CAAAA,EAASL,CAAAA,CAAAA,CAIb,OAAOK,CACT","file":"index.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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\n}\n\n/**\n * Calculates the number of business days between two dates\n * Returns the number of days to add to startDate to get endDate (can be negative)\n * If startDate and endDate are the same, returns 0\n */\nexport function getBusinessDaysBetween(\n definitions: HolidayDefinition[],\n startDate: Date,\n endDate: Date,\n): number {\n const start = new Date(startDate);\n const end = new Date(endDate);\n\n // Reset hours to avoid issues with daylight saving time or partial days\n start.setUTCHours(0, 0, 0, 0);\n end.setUTCHours(0, 0, 0, 0);\n\n if (start.getTime() === end.getTime()) return 0;\n\n const direction = start < end ? 1 : -1;\n let count = 0;\n const current = new Date(start);\n\n // If direction is positive, we count days starting from start+1 until end\n // If direction is negative, we count days starting from start-1 until end\n\n while (current.getTime() !== end.getTime()) {\n current.setUTCDate(current.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, current)) {\n count += direction;\n }\n }\n\n return count;\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -18,5 +18,11 @@ declare function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date
18
18
  * Adds (or subtracts) business days to a date
19
19
  */
20
20
  declare function addBusinessDays(definitions: HolidayDefinition[], startDate: Date, amount: number): Date;
21
+ /**
22
+ * Calculates the number of business days between two dates
23
+ * Returns the number of days to add to startDate to get endDate (can be negative)
24
+ * If startDate and endDate are the same, returns 0
25
+ */
26
+ declare function getBusinessDaysBetween(definitions: HolidayDefinition[], startDate: Date, endDate: Date): number;
21
27
 
22
- export { HolidayDefinition, addBusinessDays, checkIsBusinessDay, isWeekend };
28
+ export { HolidayDefinition, addBusinessDays, checkIsBusinessDay, getBusinessDaysBetween, isWeekend };
package/dist/index.d.ts CHANGED
@@ -18,5 +18,11 @@ declare function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date
18
18
  * Adds (or subtracts) business days to a date
19
19
  */
20
20
  declare function addBusinessDays(definitions: HolidayDefinition[], startDate: Date, amount: number): Date;
21
+ /**
22
+ * Calculates the number of business days between two dates
23
+ * Returns the number of days to add to startDate to get endDate (can be negative)
24
+ * If startDate and endDate are the same, returns 0
25
+ */
26
+ declare function getBusinessDaysBetween(definitions: HolidayDefinition[], startDate: Date, endDate: Date): number;
21
27
 
22
- export { HolidayDefinition, addBusinessDays, checkIsBusinessDay, isWeekend };
28
+ export { HolidayDefinition, addBusinessDays, checkIsBusinessDay, getBusinessDaysBetween, isWeekend };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- function d(e){let o=e%19,n=Math.floor(e/100),t=e%100,a=Math.floor(n/4),s=n%4,i=Math.floor((n+8)/25),r=Math.floor((n-i+1)/3),l=(19*o+n-a-r+15)%30,g=Math.floor(t/4),C=t%4,c=(32+2*s+2*g-l-C)%7,p=Math.floor((o+11*l+22*c)/451),U=Math.floor((l+c-7*p+114)/31),H=(l+c-7*p+114)%31+1;return new Date(Date.UTC(e,U-1,H))}function u(e,o,n,t){if(t>0){let s=new Date(Date.UTC(e,o-1,1)).getUTCDay(),r=1+(n-s+7)%7+(t-1)*7;return new Date(Date.UTC(e,o-1,r))}else {let a=new Date(Date.UTC(e,o,0)),i=(a.getUTCDay()-n+7)%7,r=a.getUTCDate()-i+(t+1)*7;return new Date(Date.UTC(e,o-1,r))}}function y(e,o){let n=e.getUTCDay();if(o==="none")return {date:e,shifted:false};let t=new Date(e);switch(o){case "emiliani":case "nextMonday":{if(n===1)return {date:e,shifted:false};let a=(8-n)%7;t.setUTCDate(e.getUTCDate()+a);break}case "observedUS":if(n===0)t.setUTCDate(e.getUTCDate()+1);else if(n===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(n===2)t.setUTCDate(e.getUTCDate()-1);else if(n===3)t.setUTCDate(e.getUTCDate()-2);else if(n===4)t.setUTCDate(e.getUTCDate()+4);else if(n===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 k(e,o){switch(e.type){case "fixed":return new Date(Date.UTC(o,e.month-1,e.day));case "nthWeekday":return u(o,e.month,e.weekday,e.n);case "easterRelative":{let n=d(o),t=new Date(n);return t.setUTCDate(n.getUTCDate()+e.offset),t}case "custom":return e.calc(o)}}function D(e){return e.toISOString().split("T")[0]}function f(e,o,n={}){return e.map(t=>{let a=k(t.rule,o);if(!a)return null;let{date:s,shifted:i}=y(a,t.shift??"none");return {date:D(s),key:t.key,name:n[t.key]??t.key,...i&&{isShifted:true}}}).filter(t=>t!==null).sort((t,a)=>t.date.localeCompare(a.date))}function h(e,o,n){let t=o.getUTCFullYear(),a=D(o);return f(e,t,n).find(i=>i.date===a)??null}function x(e,o,n){let t=D(o),a=o.getUTCFullYear(),s=f(e,a,n),i=s.find(r=>r.date>=t);return i||(s=f(e,a+1,n),i=s[0]),i??null}function m(e){let o=e.getUTCDay();return o===0||o===6}function T(e,o){return m(o)?false:h(e,o)===null}function b(e,o,n){let t=new Date(o),a=Math.abs(n),s=n>=0?1:-1;for(;a>0;)t.setUTCDate(t.getUTCDate()+s),T(e,t)&&a--;return t}export{b as addBusinessDays,y as applyShift,T as checkIsBusinessDay,h as checkIsHoliday,x as findNextHoliday,d as getEasterSunday,u as getNthWeekday,m as isWeekend,f as resolveHolidays};//# sourceMappingURL=index.js.map
1
+ function u(e){let n=e%19,o=Math.floor(e/100),t=e%100,s=Math.floor(o/4),a=o%4,i=Math.floor((o+8)/25),r=Math.floor((o-i+1)/3),l=(19*n+o-s-r+15)%30,m=Math.floor(t/4),C=t%4,c=(32+2*a+2*m-l-C)%7,T=Math.floor((n+11*l+22*c)/451),U=Math.floor((l+c-7*T+114)/31),H=(l+c-7*T+114)%31+1;return new Date(Date.UTC(e,U-1,H))}function D(e,n,o,t){if(t>0){let a=new Date(Date.UTC(e,n-1,1)).getUTCDay(),r=1+(o-a+7)%7+(t-1)*7;return new Date(Date.UTC(e,n-1,r))}else {let s=new Date(Date.UTC(e,n,0)),i=(s.getUTCDay()-o+7)%7,r=s.getUTCDate()-i+(t+1)*7;return new Date(Date.UTC(e,n-1,r))}}function d(e,n){let o=e.getUTCDay();if(n==="none")return {date:e,shifted:false};let t=new Date(e);switch(n){case "emiliani":case "nextMonday":{if(o===1)return {date:e,shifted:false};let s=(8-o)%7;t.setUTCDate(e.getUTCDate()+s);break}case "observedUS":if(o===0)t.setUTCDate(e.getUTCDate()+1);else if(o===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(o===2)t.setUTCDate(e.getUTCDate()-1);else if(o===3)t.setUTCDate(e.getUTCDate()-2);else if(o===4)t.setUTCDate(e.getUTCDate()+4);else if(o===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 k(e,n){switch(e.type){case "fixed":return new Date(Date.UTC(n,e.month-1,e.day));case "nthWeekday":return D(n,e.month,e.weekday,e.n);case "easterRelative":{let o=u(n),t=new Date(o);return t.setUTCDate(o.getUTCDate()+e.offset),t}case "custom":return e.calc(n)}}function y(e){return e.toISOString().split("T")[0]}function f(e,n,o={}){return e.map(t=>{let s=k(t.rule,n);if(!s)return null;let{date:a,shifted:i}=d(s,t.shift??"none");return {date:y(a),key:t.key,name:o[t.key]??t.key,...i&&{isShifted:true}}}).filter(t=>t!==null).sort((t,s)=>t.date.localeCompare(s.date))}function h(e,n,o){let t=n.getUTCFullYear(),s=y(n);return f(e,t,o).find(i=>i.date===s)??null}function x(e,n,o){let t=y(n),s=n.getUTCFullYear(),a=f(e,s,o),i=a.find(r=>r.date>=t);return i||(a=f(e,s+1,o),i=a[0]),i??null}function g(e){let n=e.getUTCDay();return n===0||n===6}function p(e,n){return g(n)?false:h(e,n)===null}function w(e,n,o){let t=new Date(n),s=Math.abs(o),a=o>=0?1:-1;for(;s>0;)t.setUTCDate(t.getUTCDate()+a),p(e,t)&&s--;return t}function b(e,n,o){let t=new Date(n),s=new Date(o);if(t.setUTCHours(0,0,0,0),s.setUTCHours(0,0,0,0),t.getTime()===s.getTime())return 0;let a=t<s?1:-1,i=0,r=new Date(t);for(;r.getTime()!==s.getTime();)r.setUTCDate(r.getUTCDate()+a),p(e,r)&&(i+=a);return i}export{w as addBusinessDays,d as applyShift,p as checkIsBusinessDay,h as checkIsHoliday,x as findNextHoliday,b as getBusinessDaysBetween,u as getEasterSunday,D as getNthWeekday,g as isWeekend,f as resolveHolidays};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -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","../src/core/business.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","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction"],"mappings":"AAIO,SAASA,EAAgBC,CAAAA,CAAoB,CAClD,IAAMC,CAAAA,CAAID,EAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,EAAO,GAAG,CAAA,CACzBG,CAAAA,CAAIH,CAAAA,CAAO,IACXI,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAI,CAAC,CAAA,CACpBG,CAAAA,CAAIH,CAAAA,CAAI,CAAA,CACRI,EAAI,IAAA,CAAK,KAAA,CAAA,CAAOJ,CAAAA,CAAI,CAAA,EAAK,EAAE,CAAA,CAC3BK,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,EAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,GAAK,EAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIE,CAAAA,CAAIG,EAAI,EAAA,EAAM,EAAA,CAChCE,CAAAA,CAAI,IAAA,CAAK,MAAMN,CAAAA,CAAI,CAAC,CAAA,CACpBO,CAAAA,CAAIP,EAAI,CAAA,CACRQ,CAAAA,CAAAA,CAAK,EAAA,CAAK,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S,IAAA,CAAMhC,CAAAA,EAAMA,EAAE,IAAA,EAAQ+B,CAAO,EAGjD,OAAKE,CAAAA,GACHD,EAAWX,CAAAA,CAAgBC,CAAAA,CAAa9B,CAAAA,CAAO,CAAA,CAAG+B,CAAK,CAAA,CACvDU,CAAAA,CAAOD,CAAAA,CAAS,CAAC,GAGZC,CAAAA,EAAQ,IACjB,CChFO,SAASC,EAAUpB,CAAAA,CAAqB,CAC7C,IAAMR,CAAAA,CAAMQ,EAAK,SAAA,EAAU,CAC3B,OAAOR,CAAAA,GAAQ,GAAKA,CAAAA,GAAQ,CAC9B,CAKO,SAAS6B,EAAmBb,CAAAA,CAAkCR,CAAAA,CAAqB,CACxF,OAAIoB,EAAUpB,CAAI,CAAA,CAAU,MACrBa,CAAAA,CAAeL,CAAAA,CAAaR,CAAI,CAAA,GAAM,IAC/C,CAKO,SAASsB,EACdd,CAAAA,CACAe,CAAAA,CACAC,CAAAA,CACM,CACN,IAAMtB,CAAAA,CAAS,IAAI,IAAA,CAAKqB,CAAS,EAC7BE,CAAAA,CAAY,IAAA,CAAK,GAAA,CAAID,CAAM,EACzBE,CAAAA,CAAYF,CAAAA,EAAU,CAAA,CAAI,CAAA,CAAI,GAEpC,KAAOC,CAAAA,CAAY,CAAA,EACjBvB,CAAAA,CAAO,WAAWA,CAAAA,CAAO,UAAA,EAAW,CAAIwB,CAAS,EAC7CL,CAAAA,CAAmBb,CAAAA,CAAaN,CAAM,CAAA,EACxCuB,CAAAA,EAAAA,CAIJ,OAAOvB,CACT","file":"index.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","/**\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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\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","../src/core/business.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","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction","getBusinessDaysBetween","endDate","start","end","count","current"],"mappings":"AAIO,SAASA,EAAgBC,CAAAA,CAAoB,CAClD,IAAMC,CAAAA,CAAID,CAAAA,CAAO,GACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAO,GAAG,CAAA,CACzBG,CAAAA,CAAIH,EAAO,GAAA,CACXI,CAAAA,CAAI,KAAK,KAAA,CAAMF,CAAAA,CAAI,CAAC,CAAA,CACpBG,EAAIH,CAAAA,CAAI,CAAA,CACRI,EAAI,IAAA,CAAK,KAAA,CAAA,CAAOJ,EAAI,CAAA,EAAK,EAAE,EAC3BK,CAAAA,CAAI,IAAA,CAAK,OAAOL,CAAAA,CAAII,CAAAA,CAAI,GAAK,CAAC,CAAA,CAC9BE,GAAK,EAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIE,CAAAA,CAAIG,EAAI,EAAA,EAAM,EAAA,CAChCE,EAAI,IAAA,CAAK,KAAA,CAAMN,EAAI,CAAC,CAAA,CACpBO,EAAIP,CAAAA,CAAI,CAAA,CACRQ,GAAK,EAAA,CAAK,CAAA,CAAIN,EAAI,CAAA,CAAII,CAAAA,CAAID,EAAIE,CAAAA,EAAK,CAAA,CACnCE,CAAAA,CAAI,IAAA,CAAK,OAAOX,CAAAA,CAAI,EAAA,CAAKO,EAAI,EAAA,CA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AAAA,CAAQ,UAAA,GAAeN,CAAS,CAAA,CAC/CL,EAAmBb,CAAAA,CAAawB,CAAO,IACzCD,CAAAA,EAASL,CAAAA,CAAAA,CAIb,OAAOK,CACT","file":"index.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","/**\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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\n}\n\n/**\n * Calculates the number of business days between two dates\n * Returns the number of days to add to startDate to get endDate (can be negative)\n * If startDate and endDate are the same, returns 0\n */\nexport function getBusinessDaysBetween(\n definitions: HolidayDefinition[],\n startDate: Date,\n endDate: Date,\n): number {\n const start = new Date(startDate);\n const end = new Date(endDate);\n\n // Reset hours to avoid issues with daylight saving time or partial days\n start.setUTCHours(0, 0, 0, 0);\n end.setUTCHours(0, 0, 0, 0);\n\n if (start.getTime() === end.getTime()) return 0;\n\n const direction = start < end ? 1 : -1;\n let count = 0;\n const current = new Date(start);\n\n // If direction is positive, we count days starting from start+1 until end\n // If direction is negative, we count days starting from start-1 until end\n\n while (current.getTime() !== end.getTime()) {\n current.setUTCDate(current.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, current)) {\n count += direction;\n }\n }\n\n return count;\n}\n"]}
@@ -1,2 +1,2 @@
1
- 'use strict';function h(e){let a=e%19,n=Math.floor(e/100),t=e%100,o=Math.floor(n/4),i=n%4,s=Math.floor((n+8)/25),r=Math.floor((n-s+1)/3),y=(19*a+n-o-r+15)%30,k=Math.floor(t/4),v=t%4,D=(32+2*i+2*k-y-v)%7,p=Math.floor((a+11*y+22*D)/451),x=Math.floor((y+D-7*p+114)/31),U=(y+D-7*p+114)%31+1;return new Date(Date.UTC(e,x-1,U))}function g(e,a,n,t){if(t>0){let i=new Date(Date.UTC(e,a-1,1)).getUTCDay(),r=1+(n-i+7)%7+(t-1)*7;return new Date(Date.UTC(e,a-1,r))}else {let o=new Date(Date.UTC(e,a,0)),s=(o.getUTCDay()-n+7)%7,r=o.getUTCDate()-s+(t+1)*7;return new Date(Date.UTC(e,a-1,r))}}function C(e,a){let n=e.getUTCDay();if(a==="none")return {date:e,shifted:false};let t=new Date(e);switch(a){case "emiliani":case "nextMonday":{if(n===1)return {date:e,shifted:false};let o=(8-n)%7;t.setUTCDate(e.getUTCDate()+o);break}case "observedUS":if(n===0)t.setUTCDate(e.getUTCDate()+1);else if(n===6)t.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(n===2)t.setUTCDate(e.getUTCDate()-1);else if(n===3)t.setUTCDate(e.getUTCDate()-2);else if(n===4)t.setUTCDate(e.getUTCDate()+4);else if(n===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 b(e,a){switch(e.type){case "fixed":return new Date(Date.UTC(a,e.month-1,e.day));case "nthWeekday":return g(a,e.month,e.weekday,e.n);case "easterRelative":{let n=h(a),t=new Date(n);return t.setUTCDate(n.getUTCDate()+e.offset),t}case "custom":return e.calc(a)}}function f(e){return e.toISOString().split("T")[0]}function l(e,a,n={}){return e.map(t=>{let o=b(t.rule,a);if(!o)return null;let{date:i,shifted:s}=C(o,t.shift??"none");return {date:f(i),key:t.key,name:n[t.key]??t.key,...s&&{isShifted:true}}}).filter(t=>t!==null).sort((t,o)=>t.date.localeCompare(o.date))}function u(e,a,n){let t=a.getUTCFullYear(),o=f(a);return l(e,t,n).find(s=>s.date===o)??null}function H(e,a,n){let t=f(a),o=a.getUTCFullYear(),i=l(e,o,n),s=i.find(r=>r.date>=t);return s||(i=l(e,o+1,n),s=i[0]),s??null}function M(e){let a=e.getUTCDay();return a===0||a===6}function m(e,a){return M(a)?false:u(e,a)===null}function T(e,a,n){let t=new Date(a),o=Math.abs(n),i=n>=0?1:-1;for(;o>0;)t.setUTCDate(t.getUTCDate()+i),m(e,t)&&o--;return t}var c={newYear:"A\xF1o Nuevo",epiphany:"D\xEDa de los Reyes Magos",holyThursday:"Jueves Santo",goodFriday:"Viernes Santo",easterSunday:"Domingo de Pascua",laborDay:"D\xEDa del Trabajo",ascension:"Ascensi\xF3n del Se\xF1or",corpusChristi:"Corpus Christi",christmas:"Navidad",christmasEve:"Nochebuena",newYearsEve:"Nochevieja",allSaints:"D\xEDa de Todos los Santos",saintJoseph:"D\xEDa de San Jos\xE9",sacredHeart:"Sagrado Coraz\xF3n",saintPeterPaul:"San Pedro y San Pablo",independenceDay:"D\xEDa de la Independencia",boyacaBattle:"Batalla de Boyac\xE1",assumptionMary:"Asunci\xF3n de la Virgen",columbusDay:"D\xEDa de la Raza",independenceCartagena:"Independencia de Cartagena",immaculateConception:"Inmaculada Concepci\xF3n",constitutionDay:"D\xEDa de la Constituci\xF3n",benitoJuarez:"Natalicio de Benito Ju\xE1rez",revolutionDay:"D\xEDa de la Revoluci\xF3n",virginGuadalupe:"D\xEDa de la Virgen de Guadalupe",transmissionExecutive:"Transmisi\xF3n del Poder Ejecutivo Federal",carnivalMonday:"Lunes de Carnaval",carnivalTuesday:"Martes de Carnaval",memoryDay:"D\xEDa Nacional de la Memoria por la Verdad y la Justicia",malvinasDay:"D\xEDa del Veterano y de los Ca\xEDdos en la Guerra de Malvinas",mayRevolution:"D\xEDa de la Revoluci\xF3n de Mayo",guemesDay:"Paso a la Inmortalidad del Gral. Don Mart\xEDn Miguel de G\xFCemes",belgranoDay:"Paso a la Inmortalidad del Gral. Manuel Belgrano",sanMartinDay:"Paso a la Inmortalidad del Gral. Jos\xE9 de San Mart\xEDn",diversityDay:"D\xEDa del Respeto a la Diversidad Cultural",sovereigntyDay:"D\xEDa de la Soberan\xEDa Nacional",mlkDay:"D\xEDa de Martin Luther King Jr.",presidentsDay:"D\xEDa de los Presidentes",memorialDay:"D\xEDa de los Ca\xEDdos",independenceDayUS:"D\xEDa de la Independencia",thanksgivingDay:"D\xEDa de Acci\xF3n de Gracias",veteransDay:"D\xEDa de los Veteranos"};var d=[{key:"newYear",rule:{type:"fixed",month:1,day:1}},{key:"carnivalMonday",rule:{type:"easterRelative",offset:-48}},{key:"carnivalTuesday",rule:{type:"easterRelative",offset:-47}},{key:"memoryDay",rule:{type:"fixed",month:3,day:24}},{key:"malvinasDay",rule:{type:"fixed",month:4,day:2}},{key:"goodFriday",rule:{type:"easterRelative",offset:-2}},{key:"laborDay",rule:{type:"fixed",month:5,day:1}},{key:"mayRevolution",rule:{type:"fixed",month:5,day:25}},{key:"guemesDay",rule:{type:"fixed",month:6,day:17},shift:"nearestMonday"},{key:"belgranoDay",rule:{type:"fixed",month:6,day:20}},{key:"independenceDay",rule:{type:"fixed",month:7,day:9}},{key:"sanMartinDay",rule:{type:"fixed",month:8,day:17},shift:"nearestMonday"},{key:"diversityDay",rule:{type:"fixed",month:10,day:12},shift:"nearestMonday"},{key:"sovereigntyDay",rule:{type:"fixed",month:11,day:20},shift:"nearestMonday"},{key:"immaculateConception",rule:{type:"fixed",month:12,day:8}},{key:"christmas",rule:{type:"fixed",month:12,day:25}}];function V(e,a){let n=a?.lang??c;return l(d,e,n)}function Y(e,a){let n=a?.lang??c;return u(d,e,n)}function z(e=new Date,a){let n=a?.lang??c;return H(d,e,n)}function A(e){return m(d,e)}function j(e,a){return T(d,e,a)}exports.businessDays=j;exports.getHolidays=V;exports.getNextHoliday=z;exports.isBusinessDay=A;exports.isHoliday=Y;//# sourceMappingURL=ar.cjs.map
1
+ 'use strict';function h(e){let t=e%19,n=Math.floor(e/100),a=e%100,o=Math.floor(n/4),i=n%4,s=Math.floor((n+8)/25),r=Math.floor((n-s+1)/3),y=(19*t+n-o-r+15)%30,k=Math.floor(a/4),v=a%4,f=(32+2*i+2*k-y-v)%7,p=Math.floor((t+11*y+22*f)/451),U=Math.floor((y+f-7*p+114)/31),b=(y+f-7*p+114)%31+1;return new Date(Date.UTC(e,U-1,b))}function g(e,t,n,a){if(a>0){let i=new Date(Date.UTC(e,t-1,1)).getUTCDay(),r=1+(n-i+7)%7+(a-1)*7;return new Date(Date.UTC(e,t-1,r))}else {let o=new Date(Date.UTC(e,t,0)),s=(o.getUTCDay()-n+7)%7,r=o.getUTCDate()-s+(a+1)*7;return new Date(Date.UTC(e,t-1,r))}}function C(e,t){let n=e.getUTCDay();if(t==="none")return {date:e,shifted:false};let a=new Date(e);switch(t){case "emiliani":case "nextMonday":{if(n===1)return {date:e,shifted:false};let o=(8-n)%7;a.setUTCDate(e.getUTCDate()+o);break}case "observedUS":if(n===0)a.setUTCDate(e.getUTCDate()+1);else if(n===6)a.setUTCDate(e.getUTCDate()-1);else return {date:e,shifted:false};break;case "nearestMonday":if(n===2)a.setUTCDate(e.getUTCDate()-1);else if(n===3)a.setUTCDate(e.getUTCDate()-2);else if(n===4)a.setUTCDate(e.getUTCDate()+4);else if(n===5)a.setUTCDate(e.getUTCDate()+3);else return {date:e,shifted:false};break;default:return {date:e,shifted:false}}return {date:a,shifted:true}}function M(e,t){switch(e.type){case "fixed":return new Date(Date.UTC(t,e.month-1,e.day));case "nthWeekday":return g(t,e.month,e.weekday,e.n);case "easterRelative":{let n=h(t),a=new Date(n);return a.setUTCDate(n.getUTCDate()+e.offset),a}case "custom":return e.calc(t)}}function m(e){return e.toISOString().split("T")[0]}function d(e,t,n={}){return e.map(a=>{let o=M(a.rule,t);if(!o)return null;let{date:i,shifted:s}=C(o,a.shift??"none");return {date:m(i),key:a.key,name:n[a.key]??a.key,...s&&{isShifted:true}}}).filter(a=>a!==null).sort((a,o)=>a.date.localeCompare(o.date))}function u(e,t,n){let a=t.getUTCFullYear(),o=m(t);return d(e,a,n).find(s=>s.date===o)??null}function T(e,t,n){let a=m(t),o=t.getUTCFullYear(),i=d(e,o,n),s=i.find(r=>r.date>=a);return s||(i=d(e,o+1,n),s=i[0]),s??null}function S(e){let t=e.getUTCDay();return t===0||t===6}function c(e,t){return S(t)?false:u(e,t)===null}function H(e,t,n){let a=new Date(t),o=Math.abs(n),i=n>=0?1:-1;for(;o>0;)a.setUTCDate(a.getUTCDate()+i),c(e,a)&&o--;return a}function x(e,t,n){let a=new Date(t),o=new Date(n);if(a.setUTCHours(0,0,0,0),o.setUTCHours(0,0,0,0),a.getTime()===o.getTime())return 0;let i=a<o?1:-1,s=0,r=new Date(a);for(;r.getTime()!==o.getTime();)r.setUTCDate(r.getUTCDate()+i),c(e,r)&&(s+=i);return s}var D={newYear:"A\xF1o Nuevo",epiphany:"D\xEDa de los Reyes Magos",holyThursday:"Jueves Santo",goodFriday:"Viernes Santo",easterSunday:"Domingo de Pascua",laborDay:"D\xEDa del Trabajo",ascension:"Ascensi\xF3n del Se\xF1or",corpusChristi:"Corpus Christi",christmas:"Navidad",christmasEve:"Nochebuena",newYearsEve:"Nochevieja",allSaints:"D\xEDa de Todos los Santos",saintJoseph:"D\xEDa de San Jos\xE9",sacredHeart:"Sagrado Coraz\xF3n",saintPeterPaul:"San Pedro y San Pablo",independenceDay:"D\xEDa de la Independencia",boyacaBattle:"Batalla de Boyac\xE1",assumptionMary:"Asunci\xF3n de la Virgen",columbusDay:"D\xEDa de la Raza",independenceCartagena:"Independencia de Cartagena",immaculateConception:"Inmaculada Concepci\xF3n",constitutionDay:"D\xEDa de la Constituci\xF3n",benitoJuarez:"Natalicio de Benito Ju\xE1rez",revolutionDay:"D\xEDa de la Revoluci\xF3n",virginGuadalupe:"D\xEDa de la Virgen de Guadalupe",transmissionExecutive:"Transmisi\xF3n del Poder Ejecutivo Federal",carnivalMonday:"Lunes de Carnaval",carnivalTuesday:"Martes de Carnaval",memoryDay:"D\xEDa Nacional de la Memoria por la Verdad y la Justicia",malvinasDay:"D\xEDa del Veterano y de los Ca\xEDdos en la Guerra de Malvinas",mayRevolution:"D\xEDa de la Revoluci\xF3n de Mayo",guemesDay:"Paso a la Inmortalidad del Gral. Don Mart\xEDn Miguel de G\xFCemes",belgranoDay:"Paso a la Inmortalidad del Gral. Manuel Belgrano",sanMartinDay:"Paso a la Inmortalidad del Gral. Jos\xE9 de San Mart\xEDn",diversityDay:"D\xEDa del Respeto a la Diversidad Cultural",sovereigntyDay:"D\xEDa de la Soberan\xEDa Nacional",mlkDay:"D\xEDa de Martin Luther King Jr.",presidentsDay:"D\xEDa de los Presidentes",memorialDay:"D\xEDa de los Ca\xEDdos",independenceDayUS:"D\xEDa de la Independencia",thanksgivingDay:"D\xEDa de Acci\xF3n de Gracias",veteransDay:"D\xEDa de los Veteranos"};var l=[{key:"newYear",rule:{type:"fixed",month:1,day:1}},{key:"carnivalMonday",rule:{type:"easterRelative",offset:-48}},{key:"carnivalTuesday",rule:{type:"easterRelative",offset:-47}},{key:"memoryDay",rule:{type:"fixed",month:3,day:24}},{key:"malvinasDay",rule:{type:"fixed",month:4,day:2}},{key:"goodFriday",rule:{type:"easterRelative",offset:-2}},{key:"laborDay",rule:{type:"fixed",month:5,day:1}},{key:"mayRevolution",rule:{type:"fixed",month:5,day:25}},{key:"guemesDay",rule:{type:"fixed",month:6,day:17},shift:"nearestMonday"},{key:"belgranoDay",rule:{type:"fixed",month:6,day:20}},{key:"independenceDay",rule:{type:"fixed",month:7,day:9}},{key:"sanMartinDay",rule:{type:"fixed",month:8,day:17},shift:"nearestMonday"},{key:"diversityDay",rule:{type:"fixed",month:10,day:12},shift:"nearestMonday"},{key:"sovereigntyDay",rule:{type:"fixed",month:11,day:20},shift:"nearestMonday"},{key:"immaculateConception",rule:{type:"fixed",month:12,day:8}},{key:"christmas",rule:{type:"fixed",month:12,day:25}}];function Y(e,t){let n=t?.lang??D;return d(l,e,n)}function z(e,t){let n=t?.lang??D;return u(l,e,n)}function A(e=new Date,t){let n=t?.lang??D;return T(l,e,n)}function j(e){return c(l,e)}function L(e,t){return H(l,e,t)}function K(e,t){return x(l,e,t)}exports.businessDays=L;exports.diffBusinessDays=K;exports.getHolidays=Y;exports.getNextHoliday=A;exports.isBusinessDay=j;exports.isHoliday=z;//# sourceMappingURL=ar.cjs.map
2
2
  //# sourceMappingURL=ar.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","../../src/core/business.ts","../../src/i18n/es.ts","../../src/locales/ar.ts"],"names":["getEasterSunday","year","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","resolveHolidays","definitions","names","def","rawDate","shifted","a","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction","es","getHolidays","options","isHoliday","getNextHoliday","isBusinessDay","businessDays"],"mappings":"aAIO,SAASA,CAAAA,CAAgBC,CAAAA,CAAoB,CAClD,IAAM,CAAA,CAAIA,CAAAA,CAAO,EAAA,CACXC,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMD,CAAAA,CAAO,GAAG,CAAA,CACzBE,CAAAA,CAAIF,CAAAA,CAAO,GAAA,CACXG,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,CAAK,CAAA,CAAIN,CAAAA,CAAIE,CAAAA,CAAIG,CAAAA,CAAI,EAAA,EAAM,EAAA,CAChCE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAA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,KAAA,CAAO,EAAA,CAAI,GAAA,CAAK,EAAG,CAAE,CAClE,CAAA,CAMO,SAASqB,CAAAA,CAAYlD,CAAAA,CAAcmD,CAAAA,CAAyC,CACjF,IAAMrB,CAAAA,CAAQqB,CAAAA,EAAS,IAAA,EAAQF,CAAAA,CAC/B,OAAOrB,CAAAA,CAAgBC,CAAAA,CAAa7B,CAAAA,CAAM8B,CAAK,CACjD,CAEO,SAASsB,CAAAA,CAAU/B,CAAAA,CAAY8B,CAAAA,CAA8C,CAClF,IAAMrB,CAAAA,CAAQqB,CAAAA,EAAS,IAAA,EAAQF,CAAAA,CAC/B,OAAOd,CAAAA,CAAeN,CAAAA,CAAaR,CAAAA,CAAMS,CAAK,CAChD,CAEO,SAASuB,CAAAA,CACdf,CAAAA,CAAa,IAAI,IAAA,CACjBa,CAAAA,CACgB,CAChB,IAAMrB,CAAAA,CAAQqB,CAAAA,EAAS,IAAA,EAAQF,CAAAA,CAC/B,OAAOZ,CAAAA,CAAgBR,CAAAA,CAAaS,CAAAA,CAAMR,CAAK,CACjD,CAEO,SAASwB,CAAAA,CAAcjC,CAAAA,CAAqB,CACjD,OAAOsB,CAAAA,CAAmBd,CAAAA,CAAaR,CAAI,CAC7C,CAEO,SAASkC,CAAAA,CAAalC,CAAAA,CAAYyB,CAAAA,CAAsB,CAC7D,OAAOF,CAAAA,CAAgBf,CAAAA,CAAaR,CAAAA,CAAMyB,CAAM,CAClD","file":"ar.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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\n}\n","import type { HolidayNames } from '../core/types';\n\nexport const es: HolidayNames = {\n // Comunes\n newYear: 'Año Nuevo',\n epiphany: 'Día de los Reyes Magos',\n holyThursday: 'Jueves Santo',\n goodFriday: 'Viernes Santo',\n easterSunday: 'Domingo de Pascua',\n laborDay: 'Día del Trabajo',\n ascension: 'Ascensión del Señor',\n corpusChristi: 'Corpus Christi',\n christmas: 'Navidad',\n christmasEve: 'Nochebuena',\n newYearsEve: 'Nochevieja',\n allSaints: 'Día de Todos los Santos',\n\n // Colombia\n saintJoseph: 'Día de San José',\n sacredHeart: 'Sagrado Corazón',\n saintPeterPaul: 'San Pedro y San Pablo',\n independenceDay: 'Día de la Independencia',\n boyacaBattle: 'Batalla de Boyacá',\n assumptionMary: 'Asunción de la Virgen',\n columbusDay: 'Día de la Raza',\n independenceCartagena: 'Independencia de Cartagena',\n immaculateConception: 'Inmaculada Concepción',\n\n // México\n constitutionDay: 'Día de la Constitución',\n benitoJuarez: 'Natalicio de Benito Juárez',\n revolutionDay: 'Día de la Revolución',\n virginGuadalupe: 'Día de la Virgen de Guadalupe',\n transmissionExecutive: 'Transmisión del Poder Ejecutivo Federal',\n\n // Argentina\n carnivalMonday: 'Lunes de Carnaval',\n carnivalTuesday: 'Martes de Carnaval',\n memoryDay: 'Día Nacional de la Memoria por la Verdad y la Justicia',\n malvinasDay: 'Día del Veterano y de los Caídos en la Guerra de Malvinas',\n mayRevolution: 'Día de la Revolución de Mayo',\n guemesDay: 'Paso a la Inmortalidad del Gral. Don Martín Miguel de Güemes',\n belgranoDay: 'Paso a la Inmortalidad del Gral. Manuel Belgrano',\n sanMartinDay: 'Paso a la Inmortalidad del Gral. José de San Martín',\n diversityDay: 'Día del Respeto a la Diversidad Cultural',\n sovereigntyDay: 'Día de la Soberanía Nacional',\n\n // USA\n mlkDay: 'Día de Martin Luther King Jr.',\n presidentsDay: 'Día de los Presidentes',\n memorialDay: 'Día de los Caídos',\n independenceDayUS: 'Día de la Independencia',\n thanksgivingDay: 'Día de Acción de Gracias',\n veteransDay: 'Día de los Veteranos',\n};\n","import type { HolidayDefinition, Holiday, HolidayNames } from '../core/types';\nimport { resolveHolidays, checkIsHoliday, findNextHoliday } from '../core/engine';\nimport { checkIsBusinessDay, addBusinessDays } from '../core/business';\nimport { es } from '../i18n/es';\n\nconst definitions: HolidayDefinition[] = [\n { key: 'newYear', rule: { type: 'fixed', month: 1, day: 1 } },\n { key: 'carnivalMonday', rule: { type: 'easterRelative', offset: -48 } },\n { key: 'carnivalTuesday', rule: { type: 'easterRelative', offset: -47 } },\n { key: 'memoryDay', rule: { type: 'fixed', month: 3, day: 24 } },\n { key: 'malvinasDay', rule: { type: 'fixed', month: 4, day: 2 } },\n { key: 'goodFriday', rule: { type: 'easterRelative', offset: -2 } },\n { key: 'laborDay', rule: { type: 'fixed', month: 5, day: 1 } },\n { key: 'mayRevolution', rule: { type: 'fixed', month: 5, day: 25 } },\n {\n key: 'guemesDay',\n rule: { type: 'fixed', month: 6, day: 17 },\n shift: 'nearestMonday',\n },\n { key: 'belgranoDay', rule: { type: 'fixed', month: 6, day: 20 } },\n { key: 'independenceDay', rule: { type: 'fixed', month: 7, day: 9 } },\n {\n key: 'sanMartinDay',\n rule: { type: 'fixed', month: 8, day: 17 },\n shift: 'nearestMonday',\n },\n {\n key: 'diversityDay',\n rule: { type: 'fixed', month: 10, day: 12 },\n shift: 'nearestMonday',\n },\n {\n key: 'sovereigntyDay',\n rule: { type: 'fixed', month: 11, day: 20 },\n shift: 'nearestMonday',\n },\n { key: 'immaculateConception', rule: { type: 'fixed', month: 12, day: 8 } },\n { key: 'christmas', rule: { type: 'fixed', month: 12, day: 25 } },\n];\n\nexport interface GetHolidaysOptions {\n lang?: HolidayNames;\n}\n\nexport function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[] {\n const names = options?.lang ?? es;\n return resolveHolidays(definitions, year, names);\n}\n\nexport function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null {\n const names = options?.lang ?? es;\n return checkIsHoliday(definitions, date, names);\n}\n\nexport function getNextHoliday(\n from: Date = new Date(),\n options?: GetHolidaysOptions,\n): Holiday | null {\n const names = options?.lang ?? es;\n return findNextHoliday(definitions, from, names);\n}\n\nexport function isBusinessDay(date: Date): boolean {\n return checkIsBusinessDay(definitions, date);\n}\n\nexport function businessDays(date: Date, amount: number): Date {\n return addBusinessDays(definitions, date, amount);\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","../../src/core/business.ts","../../src/i18n/es.ts","../../src/locales/ar.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","resolveHolidays","definitions","names","def","rawDate","shifted","checkIsHoliday","isoDate","findNextHoliday","from","isoFrom","holidays","next","isWeekend","checkIsBusinessDay","addBusinessDays","startDate","amount","remaining","direction","getBusinessDaysBetween","endDate","start","end","count","current","es","getHolidays","options","isHoliday","getNextHoliday","isBusinessDay","businessDays","diffBusinessDays"],"mappings":"aAIO,SAASA,CAAAA,CAAgBC,CAAAA,CAAoB,CAClD,IAAMC,CAAAA,CAAID,CAAAA,CAAO,EAAA,CACXE,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAMF,CAAAA,CAAO,GAAG,EACzBG,CAAAA,CAAIH,CAAAA,CAAO,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,GAAK,EAAE,CAAA,CAC3BK,CAAAA,CAAI,IAAA,CAAK,KAAA,CAAA,CAAOL,CAAAA,CAAII,CAAAA,CAAI,CAAA,EAAK,CAAC,CAAA,CAC9BE,CAAAA,CAA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P,CAAK,CACjD,CAEO,SAAS6B,CAAAA,CAActC,CAAAA,CAAqB,CACjD,OAAOqB,CAAAA,CAAmBb,CAAAA,CAAaR,CAAI,CAC7C,CAEO,SAASuC,CAAAA,CAAavC,CAAAA,CAAYwB,EAAsB,CAC7D,OAAOF,CAAAA,CAAgBd,CAAAA,CAAaR,CAAAA,CAAMwB,CAAM,CAClD,CAEO,SAASgB,CAAAA,CAAiBjB,CAAAA,CAAiBK,CAAAA,CAAuB,CACvE,OAAOD,CAAAA,CAAuBnB,CAAAA,CAAae,CAAAA,CAAWK,CAAO,CAC/D","file":"ar.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 return date.toISOString().split('T')[0];\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 return definitions\n .map((def) => {\n const rawDate = resolveRule(def.rule, year);\n if (!rawDate) return null;\n\n const { date, shifted } = applyShift(rawDate, def.shift ?? 'none');\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 const year = date.getUTCFullYear();\n const isoDate = toISODate(date);\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 const isoFrom = toISODate(from);\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","import type { HolidayDefinition } from './types';\nimport { checkIsHoliday } from './engine';\n\n/**\n * Checks if a date is a weekend (Saturday or Sunday)\n * Uses UTC date to avoid timezone issues\n */\nexport function isWeekend(date: Date): boolean {\n const day = date.getUTCDay();\n return day === 0 || day === 6; // 0 = Sunday, 6 = Saturday\n}\n\n/**\n * Checks if a date is a business day (not weekend AND not holiday)\n */\nexport function checkIsBusinessDay(definitions: HolidayDefinition[], date: Date): boolean {\n if (isWeekend(date)) return false;\n return checkIsHoliday(definitions, date) === null;\n}\n\n/**\n * Adds (or subtracts) business days to a date\n */\nexport function addBusinessDays(\n definitions: HolidayDefinition[],\n startDate: Date,\n amount: number,\n): Date {\n const result = new Date(startDate);\n let remaining = Math.abs(amount);\n const direction = amount >= 0 ? 1 : -1;\n\n while (remaining > 0) {\n result.setUTCDate(result.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, result)) {\n remaining--;\n }\n }\n\n return result;\n}\n\n/**\n * Calculates the number of business days between two dates\n * Returns the number of days to add to startDate to get endDate (can be negative)\n * If startDate and endDate are the same, returns 0\n */\nexport function getBusinessDaysBetween(\n definitions: HolidayDefinition[],\n startDate: Date,\n endDate: Date,\n): number {\n const start = new Date(startDate);\n const end = new Date(endDate);\n\n // Reset hours to avoid issues with daylight saving time or partial days\n start.setUTCHours(0, 0, 0, 0);\n end.setUTCHours(0, 0, 0, 0);\n\n if (start.getTime() === end.getTime()) return 0;\n\n const direction = start < end ? 1 : -1;\n let count = 0;\n const current = new Date(start);\n\n // If direction is positive, we count days starting from start+1 until end\n // If direction is negative, we count days starting from start-1 until end\n\n while (current.getTime() !== end.getTime()) {\n current.setUTCDate(current.getUTCDate() + direction);\n if (checkIsBusinessDay(definitions, current)) {\n count += direction;\n }\n }\n\n return count;\n}\n","import type { HolidayNames } from '../core/types';\n\nexport const es: HolidayNames = {\n // Comunes\n newYear: 'Año Nuevo',\n epiphany: 'Día de los Reyes Magos',\n holyThursday: 'Jueves Santo',\n goodFriday: 'Viernes Santo',\n easterSunday: 'Domingo de Pascua',\n laborDay: 'Día del Trabajo',\n ascension: 'Ascensión del Señor',\n corpusChristi: 'Corpus Christi',\n christmas: 'Navidad',\n christmasEve: 'Nochebuena',\n newYearsEve: 'Nochevieja',\n allSaints: 'Día de Todos los Santos',\n\n // Colombia\n saintJoseph: 'Día de San José',\n sacredHeart: 'Sagrado Corazón',\n saintPeterPaul: 'San Pedro y San Pablo',\n independenceDay: 'Día de la Independencia',\n boyacaBattle: 'Batalla de Boyacá',\n assumptionMary: 'Asunción de la Virgen',\n columbusDay: 'Día de la Raza',\n independenceCartagena: 'Independencia de Cartagena',\n immaculateConception: 'Inmaculada Concepción',\n\n // México\n constitutionDay: 'Día de la Constitución',\n benitoJuarez: 'Natalicio de Benito Juárez',\n revolutionDay: 'Día de la Revolución',\n virginGuadalupe: 'Día de la Virgen de Guadalupe',\n transmissionExecutive: 'Transmisión del Poder Ejecutivo Federal',\n\n // Argentina\n carnivalMonday: 'Lunes de Carnaval',\n carnivalTuesday: 'Martes de Carnaval',\n memoryDay: 'Día Nacional de la Memoria por la Verdad y la Justicia',\n malvinasDay: 'Día del Veterano y de los Caídos en la Guerra de Malvinas',\n mayRevolution: 'Día de la Revolución de Mayo',\n guemesDay: 'Paso a la Inmortalidad del Gral. Don Martín Miguel de Güemes',\n belgranoDay: 'Paso a la Inmortalidad del Gral. Manuel Belgrano',\n sanMartinDay: 'Paso a la Inmortalidad del Gral. José de San Martín',\n diversityDay: 'Día del Respeto a la Diversidad Cultural',\n sovereigntyDay: 'Día de la Soberanía Nacional',\n\n // USA\n mlkDay: 'Día de Martin Luther King Jr.',\n presidentsDay: 'Día de los Presidentes',\n memorialDay: 'Día de los Caídos',\n independenceDayUS: 'Día de la Independencia',\n thanksgivingDay: 'Día de Acción de Gracias',\n veteransDay: 'Día de los Veteranos',\n};\n","import type { HolidayDefinition, Holiday, HolidayNames } from '../core/types';\nimport { resolveHolidays, checkIsHoliday, findNextHoliday } from '../core/engine';\nimport { checkIsBusinessDay, addBusinessDays, getBusinessDaysBetween } from '../core/business';\nimport { es } from '../i18n/es';\n\nconst definitions: HolidayDefinition[] = [\n { key: 'newYear', rule: { type: 'fixed', month: 1, day: 1 } },\n { key: 'carnivalMonday', rule: { type: 'easterRelative', offset: -48 } },\n { key: 'carnivalTuesday', rule: { type: 'easterRelative', offset: -47 } },\n { key: 'memoryDay', rule: { type: 'fixed', month: 3, day: 24 } },\n { key: 'malvinasDay', rule: { type: 'fixed', month: 4, day: 2 } },\n { key: 'goodFriday', rule: { type: 'easterRelative', offset: -2 } },\n { key: 'laborDay', rule: { type: 'fixed', month: 5, day: 1 } },\n { key: 'mayRevolution', rule: { type: 'fixed', month: 5, day: 25 } },\n {\n key: 'guemesDay',\n rule: { type: 'fixed', month: 6, day: 17 },\n shift: 'nearestMonday',\n },\n { key: 'belgranoDay', rule: { type: 'fixed', month: 6, day: 20 } },\n { key: 'independenceDay', rule: { type: 'fixed', month: 7, day: 9 } },\n {\n key: 'sanMartinDay',\n rule: { type: 'fixed', month: 8, day: 17 },\n shift: 'nearestMonday',\n },\n {\n key: 'diversityDay',\n rule: { type: 'fixed', month: 10, day: 12 },\n shift: 'nearestMonday',\n },\n {\n key: 'sovereigntyDay',\n rule: { type: 'fixed', month: 11, day: 20 },\n shift: 'nearestMonday',\n },\n { key: 'immaculateConception', rule: { type: 'fixed', month: 12, day: 8 } },\n { key: 'christmas', rule: { type: 'fixed', month: 12, day: 25 } },\n];\n\nexport interface GetHolidaysOptions {\n lang?: HolidayNames;\n}\n\nexport function getHolidays(year: number, options?: GetHolidaysOptions): Holiday[] {\n const names = options?.lang ?? es;\n return resolveHolidays(definitions, year, names);\n}\n\nexport function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday | null {\n const names = options?.lang ?? es;\n return checkIsHoliday(definitions, date, names);\n}\n\nexport function getNextHoliday(\n from: Date = new Date(),\n options?: GetHolidaysOptions,\n): Holiday | null {\n const names = options?.lang ?? es;\n return findNextHoliday(definitions, from, names);\n}\n\nexport function isBusinessDay(date: Date): boolean {\n return checkIsBusinessDay(definitions, date);\n}\n\nexport function businessDays(date: Date, amount: number): Date {\n return addBusinessDays(definitions, date, amount);\n}\n\nexport function diffBusinessDays(startDate: Date, endDate: Date): number {\n return getBusinessDaysBetween(definitions, startDate, endDate);\n}\n"]}
@@ -8,5 +8,6 @@ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday |
8
8
  declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
9
  declare function isBusinessDay(date: Date): boolean;
10
10
  declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
11
12
 
12
- export { type GetHolidaysOptions, businessDays, getHolidays, getNextHoliday, isBusinessDay, isHoliday };
13
+ export { type GetHolidaysOptions, businessDays, diffBusinessDays, getHolidays, getNextHoliday, isBusinessDay, isHoliday };
@@ -8,5 +8,6 @@ declare function isHoliday(date: Date, options?: GetHolidaysOptions): Holiday |
8
8
  declare function getNextHoliday(from?: Date, options?: GetHolidaysOptions): Holiday | null;
9
9
  declare function isBusinessDay(date: Date): boolean;
10
10
  declare function businessDays(date: Date, amount: number): Date;
11
+ declare function diffBusinessDays(startDate: Date, endDate: Date): number;
11
12
 
12
- export { type GetHolidaysOptions, businessDays, getHolidays, getNextHoliday, isBusinessDay, isHoliday };
13
+ export { type GetHolidaysOptions, businessDays, diffBusinessDays, getHolidays, getNextHoliday, isBusinessDay, isHoliday };