@intech-software/chronera 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/core/local-date.d.ts +1 -0
  2. package/dist/core/local-date.js +1 -0
  3. package/dist/core/local-date.js.map +1 -1
  4. package/dist/format/format-pattern.js +97 -2
  5. package/dist/format/format-pattern.js.map +1 -1
  6. package/dist/format/pattern-scanner.js +9 -0
  7. package/dist/format/pattern-scanner.js.map +1 -1
  8. package/dist/holidays/countries/ae.d.ts +6 -0
  9. package/dist/holidays/countries/ae.js +70 -0
  10. package/dist/holidays/countries/ae.js.map +1 -0
  11. package/dist/holidays/countries/au.d.ts +6 -0
  12. package/dist/holidays/countries/au.js +79 -0
  13. package/dist/holidays/countries/au.js.map +1 -0
  14. package/dist/holidays/countries/cn.d.ts +6 -0
  15. package/dist/holidays/countries/cn.js +57 -0
  16. package/dist/holidays/countries/cn.js.map +1 -0
  17. package/dist/holidays/countries/de.d.ts +6 -0
  18. package/dist/holidays/countries/de.js +81 -0
  19. package/dist/holidays/countries/de.js.map +1 -0
  20. package/dist/holidays/countries/fr.d.ts +6 -0
  21. package/dist/holidays/countries/fr.js +97 -0
  22. package/dist/holidays/countries/fr.js.map +1 -0
  23. package/dist/holidays/countries/gb.d.ts +6 -0
  24. package/dist/holidays/countries/gb.js +80 -0
  25. package/dist/holidays/countries/gb.js.map +1 -0
  26. package/dist/holidays/countries/hk.d.ts +6 -0
  27. package/dist/holidays/countries/hk.js +87 -0
  28. package/dist/holidays/countries/hk.js.map +1 -0
  29. package/dist/holidays/countries/in.d.ts +6 -0
  30. package/dist/holidays/countries/in.js +52 -0
  31. package/dist/holidays/countries/in.js.map +1 -0
  32. package/dist/holidays/countries/index.d.ts +18 -0
  33. package/dist/holidays/countries/index.js +34 -0
  34. package/dist/holidays/countries/index.js.map +1 -0
  35. package/dist/holidays/countries/ir.d.ts +7 -0
  36. package/dist/holidays/countries/ir.js +93 -0
  37. package/dist/holidays/countries/ir.js.map +1 -0
  38. package/dist/holidays/countries/jp.d.ts +6 -0
  39. package/dist/holidays/countries/jp.js +140 -0
  40. package/dist/holidays/countries/jp.js.map +1 -0
  41. package/dist/holidays/countries/sa.d.ts +7 -0
  42. package/dist/holidays/countries/sa.js +56 -0
  43. package/dist/holidays/countries/sa.js.map +1 -0
  44. package/dist/holidays/countries/sg.d.ts +6 -0
  45. package/dist/holidays/countries/sg.js +71 -0
  46. package/dist/holidays/countries/sg.js.map +1 -0
  47. package/dist/holidays/countries/th.d.ts +6 -0
  48. package/dist/holidays/countries/th.js +151 -0
  49. package/dist/holidays/countries/th.js.map +1 -0
  50. package/dist/holidays/countries/tw.d.ts +6 -0
  51. package/dist/holidays/countries/tw.js +57 -0
  52. package/dist/holidays/countries/tw.js.map +1 -0
  53. package/dist/holidays/countries/us.d.ts +6 -0
  54. package/dist/holidays/countries/us.js +112 -0
  55. package/dist/holidays/countries/us.js.map +1 -0
  56. package/dist/holidays/easter.d.ts +23 -0
  57. package/dist/holidays/easter.js +49 -0
  58. package/dist/holidays/easter.js.map +1 -0
  59. package/dist/holidays/index.d.ts +5 -0
  60. package/dist/holidays/index.js +6 -0
  61. package/dist/holidays/index.js.map +1 -0
  62. package/dist/holidays/registry.d.ts +14 -0
  63. package/dist/holidays/registry.js +79 -0
  64. package/dist/holidays/registry.js.map +1 -0
  65. package/dist/holidays/rules/easter-rule.d.ts +5 -0
  66. package/dist/holidays/rules/easter-rule.js +26 -0
  67. package/dist/holidays/rules/easter-rule.js.map +1 -0
  68. package/dist/holidays/rules/fixed-rule.d.ts +5 -0
  69. package/dist/holidays/rules/fixed-rule.js +72 -0
  70. package/dist/holidays/rules/fixed-rule.js.map +1 -0
  71. package/dist/holidays/rules/floating-rule.d.ts +6 -0
  72. package/dist/holidays/rules/floating-rule.js +53 -0
  73. package/dist/holidays/rules/floating-rule.js.map +1 -0
  74. package/dist/holidays/rules/hijri-rule.d.ts +6 -0
  75. package/dist/holidays/rules/hijri-rule.js +44 -0
  76. package/dist/holidays/rules/hijri-rule.js.map +1 -0
  77. package/dist/holidays/rules/index.d.ts +9 -0
  78. package/dist/holidays/rules/index.js +26 -0
  79. package/dist/holidays/rules/index.js.map +1 -0
  80. package/dist/holidays/types.d.ts +106 -0
  81. package/dist/holidays/types.js +2 -0
  82. package/dist/holidays/types.js.map +1 -0
  83. package/dist/index.d.ts +8 -3
  84. package/dist/index.js +5 -2
  85. package/dist/index.js.map +1 -1
  86. package/dist/operations/business-days.d.ts +30 -14
  87. package/dist/operations/business-days.js +115 -37
  88. package/dist/operations/business-days.js.map +1 -1
  89. package/dist/operations/holidays.d.ts +15 -0
  90. package/dist/operations/holidays.js +36 -0
  91. package/dist/operations/holidays.js.map +1 -0
  92. package/dist/operations/timezone.d.ts +28 -0
  93. package/dist/operations/timezone.js +120 -0
  94. package/dist/operations/timezone.js.map +1 -0
  95. package/dist/public-types.d.ts +16 -0
  96. package/dist/public-types.js.map +1 -1
  97. package/package.json +10 -1
@@ -0,0 +1,26 @@
1
+ import { evaluateFixedRule } from "./fixed-rule.js";
2
+ import { evaluateFloatingRule } from "./floating-rule.js";
3
+ import { evaluateEasterRule } from "./easter-rule.js";
4
+ import { evaluateHijriRule } from "./hijri-rule.js";
5
+ /**
6
+ * Dispatches and evaluates any HolidayRule for a specified Gregorian year.
7
+ */
8
+ export function evaluateRule(rule, year, country, includeObserved = true) {
9
+ switch (rule.type) {
10
+ case "fixed":
11
+ return evaluateFixedRule(rule, year, country, includeObserved);
12
+ case "floating":
13
+ return evaluateFloatingRule(rule, year, country);
14
+ case "easter":
15
+ return evaluateEasterRule(rule, year, country);
16
+ case "hijri":
17
+ return evaluateHijriRule(rule, year, country);
18
+ case "custom":
19
+ return rule.evaluate(year);
20
+ }
21
+ }
22
+ export * from "./fixed-rule.js";
23
+ export * from "./floating-rule.js";
24
+ export * from "./easter-rule.js";
25
+ export * from "./hijri-rule.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/holidays/rules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAiB,EACjB,IAAY,EACZ,OAAoC,EACpC,eAAe,GAAG,IAAI;IAEtB,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,OAAO;YACV,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QACjE,KAAK,UAAU;YACb,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACnD,KAAK,QAAQ;YACX,OAAO,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QACjD,KAAK,OAAO;YACV,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC","sourcesContent":["import { evaluateFixedRule } from \"./fixed-rule.js\";\nimport { evaluateFloatingRule } from \"./floating-rule.js\";\nimport { evaluateEasterRule } from \"./easter-rule.js\";\nimport { evaluateHijriRule } from \"./hijri-rule.js\";\n\nimport type { HolidayRule, PublicHoliday, CountryCode } from \"../types.js\";\n\n/**\n * Dispatches and evaluates any HolidayRule for a specified Gregorian year.\n */\nexport function evaluateRule(\n rule: HolidayRule,\n year: number,\n country: CountryCode | (string & {}),\n includeObserved = true,\n): readonly PublicHoliday[] {\n switch (rule.type) {\n case \"fixed\":\n return evaluateFixedRule(rule, year, country, includeObserved);\n case \"floating\":\n return evaluateFloatingRule(rule, year, country);\n case \"easter\":\n return evaluateEasterRule(rule, year, country);\n case \"hijri\":\n return evaluateHijriRule(rule, year, country);\n case \"custom\":\n return rule.evaluate(year);\n }\n}\n\nexport * from \"./fixed-rule.js\";\nexport * from \"./floating-rule.js\";\nexport * from \"./easter-rule.js\";\nexport * from \"./hijri-rule.js\";\n"]}
@@ -0,0 +1,106 @@
1
+ import type { LocalDate } from "../public-types.js";
2
+ /**
3
+ * Supported 15 country codes (ISO 3166-1 alpha-2).
4
+ */
5
+ export type CountryCode = "TH" | "JP" | "SA" | "AE" | "IR" | "TW" | "IN" | "SG" | "US" | "GB" | "DE" | "FR" | "AU" | "CN" | "HK";
6
+ /**
7
+ * Substitution rule when a holiday falls on a weekend or statutory non-working day.
8
+ */
9
+ export type ObservedRollRule = "none" | "sunday-to-monday" | "weekend-to-monday" | "sat-to-fri-sun-to-mon" | "iran-roll";
10
+ /**
11
+ * Fixed solar calendar date rule (e.g., Songkran April 13-15, New Year Jan 1).
12
+ */
13
+ export interface FixedHolidayRule {
14
+ readonly type: "fixed";
15
+ readonly id: string;
16
+ readonly month: number;
17
+ readonly day: number;
18
+ readonly name: string;
19
+ readonly nameEn: string;
20
+ readonly observed?: ObservedRollRule;
21
+ readonly validFromYear?: number;
22
+ readonly validUntilYear?: number;
23
+ }
24
+ /**
25
+ * Floating weekday rule (e.g., US Thanksgiving 4th Thursday of November, Japan Happy Monday 2nd Monday).
26
+ */
27
+ export interface FloatingHolidayRule {
28
+ readonly type: "floating";
29
+ readonly id: string;
30
+ readonly month: number;
31
+ readonly weekday: number;
32
+ readonly occurrence: 1 | 2 | 3 | 4 | 5 | -1;
33
+ readonly name: string;
34
+ readonly nameEn: string;
35
+ readonly validFromYear?: number;
36
+ readonly validUntilYear?: number;
37
+ }
38
+ /**
39
+ * Western Christian astronomical Easter cycle rule (Meeus/Jones/Butcher algorithm).
40
+ * e.g., Good Friday (offset -2), Easter Monday (offset +1), Ascension (offset +39).
41
+ */
42
+ export interface EasterHolidayRule {
43
+ readonly type: "easter";
44
+ readonly id: string;
45
+ readonly offsetDays: number;
46
+ readonly name: string;
47
+ readonly nameEn: string;
48
+ readonly validFromYear?: number;
49
+ readonly validUntilYear?: number;
50
+ }
51
+ /**
52
+ * Islamic Lunar Hijri holiday rule mapped to solar Gregorian years via Chronera Hijri adapters.
53
+ * e.g., Eid al-Fitr (1 Shawwal = Month 10 Day 1), Eid al-Adha (10 Dhu al-Hijjah = Month 12 Day 10).
54
+ */
55
+ export interface HijriHolidayRule {
56
+ readonly type: "hijri";
57
+ readonly id: string;
58
+ readonly hijriMonth: number;
59
+ readonly hijriDay: number;
60
+ readonly durationDays?: number;
61
+ readonly name: string;
62
+ readonly nameEn: string;
63
+ readonly validFromYear?: number;
64
+ readonly validUntilYear?: number;
65
+ }
66
+ /**
67
+ * Dynamic custom rule for arbitrary mathematical or cultural evaluations.
68
+ */
69
+ export interface CustomHolidayRule {
70
+ readonly type: "custom";
71
+ readonly id: string;
72
+ readonly name: string;
73
+ readonly nameEn: string;
74
+ readonly evaluate: (year: number) => readonly PublicHoliday[];
75
+ }
76
+ export type HolidayRule = FixedHolidayRule | FloatingHolidayRule | EasterHolidayRule | HijriHolidayRule | CustomHolidayRule;
77
+ /**
78
+ * Evaluated public holiday representation.
79
+ */
80
+ export interface PublicHoliday {
81
+ readonly id: string;
82
+ readonly date: LocalDate;
83
+ readonly name: string;
84
+ readonly nameEn: string;
85
+ readonly country: CountryCode | (string & {});
86
+ readonly isObserved: boolean;
87
+ readonly originalDate?: LocalDate;
88
+ }
89
+ /**
90
+ * Complete country holiday calendar definition.
91
+ */
92
+ export interface HolidayCalendar {
93
+ readonly country: CountryCode | (string & {});
94
+ readonly countryName?: string;
95
+ readonly defaultWeekendDays?: readonly number[];
96
+ readonly rules: readonly HolidayRule[];
97
+ }
98
+ /**
99
+ * Options for holiday queries.
100
+ */
101
+ export interface HolidayOptions {
102
+ /** Include substituted/observed holidays when falling on weekends (default: true) */
103
+ readonly includeObserved?: boolean;
104
+ /** Additional custom holidays to include */
105
+ readonly additionalHolidays?: readonly LocalDate[];
106
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/holidays/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { LocalDate } from \"../public-types.js\";\n\n/**\n * Supported 15 country codes (ISO 3166-1 alpha-2).\n */\nexport type CountryCode =\n | \"TH\" // Thailand 🇹🇭\n | \"JP\" // Japan 🇯🇵\n | \"SA\" // Saudi Arabia 🇸🇦\n | \"AE\" // United Arab Emirates 🇦🇪\n | \"IR\" // Iran 🇮🇷\n | \"TW\" // Taiwan 🇹🇼\n | \"IN\" // India 🇮🇳\n | \"SG\" // Singapore 🇸🇬\n | \"US\" // United States 🇺🇸\n | \"GB\" // United Kingdom 🇬🇧\n | \"DE\" // Germany 🇩🇪\n | \"FR\" // France 🇫🇷\n | \"AU\" // Australia 🇦🇺\n | \"CN\" // China 🇨🇳\n | \"HK\"; // Hong Kong 🇭🇰\n\n/**\n * Substitution rule when a holiday falls on a weekend or statutory non-working day.\n */\nexport type ObservedRollRule =\n | \"none\"\n | \"sunday-to-monday\" // If Sunday -> roll to Monday (e.g., Thailand, Hong Kong, Japan)\n | \"weekend-to-monday\" // If Saturday or Sunday -> roll to Monday (e.g., UK, Singapore)\n | \"sat-to-fri-sun-to-mon\" // If Saturday -> Friday, If Sunday -> Monday (e.g., US Federal)\n | \"iran-roll\"; // Iran weekend roll (Thursday/Friday)\n\n/**\n * Fixed solar calendar date rule (e.g., Songkran April 13-15, New Year Jan 1).\n */\nexport interface FixedHolidayRule {\n readonly type: \"fixed\";\n readonly id: string;\n readonly month: number; // 1-12\n readonly day: number; // 1-31\n readonly name: string;\n readonly nameEn: string;\n readonly observed?: ObservedRollRule;\n readonly validFromYear?: number;\n readonly validUntilYear?: number;\n}\n\n/**\n * Floating weekday rule (e.g., US Thanksgiving 4th Thursday of November, Japan Happy Monday 2nd Monday).\n */\nexport interface FloatingHolidayRule {\n readonly type: \"floating\";\n readonly id: string;\n readonly month: number; // 1-12\n readonly weekday: number; // 1 (Mon) .. 7 (Sun)\n readonly occurrence: 1 | 2 | 3 | 4 | 5 | -1; // -1 represents the last weekday of the month\n readonly name: string;\n readonly nameEn: string;\n readonly validFromYear?: number;\n readonly validUntilYear?: number;\n}\n\n/**\n * Western Christian astronomical Easter cycle rule (Meeus/Jones/Butcher algorithm).\n * e.g., Good Friday (offset -2), Easter Monday (offset +1), Ascension (offset +39).\n */\nexport interface EasterHolidayRule {\n readonly type: \"easter\";\n readonly id: string;\n readonly offsetDays: number;\n readonly name: string;\n readonly nameEn: string;\n readonly validFromYear?: number;\n readonly validUntilYear?: number;\n}\n\n/**\n * Islamic Lunar Hijri holiday rule mapped to solar Gregorian years via Chronera Hijri adapters.\n * e.g., Eid al-Fitr (1 Shawwal = Month 10 Day 1), Eid al-Adha (10 Dhu al-Hijjah = Month 12 Day 10).\n */\nexport interface HijriHolidayRule {\n readonly type: \"hijri\";\n readonly id: string;\n readonly hijriMonth: number; // 1-12\n readonly hijriDay: number; // 1-30\n readonly durationDays?: number; // default 1\n readonly name: string;\n readonly nameEn: string;\n readonly validFromYear?: number;\n readonly validUntilYear?: number;\n}\n\n/**\n * Dynamic custom rule for arbitrary mathematical or cultural evaluations.\n */\nexport interface CustomHolidayRule {\n readonly type: \"custom\";\n readonly id: string;\n readonly name: string;\n readonly nameEn: string;\n readonly evaluate: (year: number) => readonly PublicHoliday[];\n}\n\nexport type HolidayRule =\n | FixedHolidayRule\n | FloatingHolidayRule\n | EasterHolidayRule\n | HijriHolidayRule\n | CustomHolidayRule;\n\n/**\n * Evaluated public holiday representation.\n */\nexport interface PublicHoliday {\n readonly id: string;\n readonly date: LocalDate;\n readonly name: string;\n readonly nameEn: string;\n readonly country: CountryCode | (string & {});\n readonly isObserved: boolean;\n readonly originalDate?: LocalDate;\n}\n\n/**\n * Complete country holiday calendar definition.\n */\nexport interface HolidayCalendar {\n readonly country: CountryCode | (string & {});\n readonly countryName?: string;\n readonly defaultWeekendDays?: readonly number[]; // 1 = Mon ... 7 = Sun\n readonly rules: readonly HolidayRule[];\n}\n\n/**\n * Options for holiday queries.\n */\nexport interface HolidayOptions {\n /** Include substituted/observed holidays when falling on weekends (default: true) */\n readonly includeObserved?: boolean;\n /** Additional custom holidays to include */\n readonly additionalHolidays?: readonly LocalDate[];\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,12 @@ export { createChronera } from "./create-chronera.js";
2
2
  export { compareInstants, compareLocalDates, sameAbsoluteDate, sameCalendarDate, } from "./operations/compare.js";
3
3
  export { getAbsoluteDay, isBefore, isAfter, isEqual, isSameDay, isBetween, isToday, addDays, subtractDays, addMonths, subtractMonths, addYears, subtractYears, diffInDays, startOfMonth, endOfMonth, startOfYear, endOfYear, } from "./operations/convenience.js";
4
4
  export { startOfDay, endOfDay, isPast, isFuture, addHours, subtractHours, addMinutes, subtractMinutes, addSeconds, subtractSeconds, } from "./operations/time-convenience.js";
5
- export { isWeekend, isWeekday, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
5
+ export { isWeekend, isWeekday, isBusinessDay, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
6
+ export { isPublicHoliday, getPublicHolidays, getHolidayDetails, } from "./operations/holidays.js";
7
+ export { registerHolidayCalendar, getHolidayCalendar, resolveAnnualHolidays, calculateEasterSunday, calculateGoodFriday, calculateEasterMonday, calculateAscensionDay, calculateWhitMonday, BUILT_IN_HOLIDAYS, thailandHolidays, japanHolidays, saudiArabiaHolidays, uaeHolidays, iranHolidays, taiwanHolidays, indiaHolidays, singaporeHolidays, unitedStatesHolidays, unitedKingdomHolidays, germanyHolidays, franceHolidays, australiaHolidays, chinaHolidays, hongKongHolidays, } from "./holidays/index.js";
8
+ export type { CountryCode, PublicHoliday, HolidayCalendar, HolidayRule, HolidayOptions, ObservedRollRule, } from "./holidays/types.js";
9
+ export type { BusinessDaysOptions } from "./operations/business-days.js";
10
+ export { formatInTimeZone, getTimeZoneOffset, isSameTimeZone, } from "./operations/timezone.js";
6
11
  export { convertCalendarDate } from "./operations/convert-calendar-date.js";
7
12
  export { daysInMonth, getCalendarCapabilities, isLeapYear, isValidCalendarDate, } from "./operations/validate.js";
8
13
  export { getIsoWeek, formatIsoWeek } from "./operations/iso-week.js";
@@ -14,9 +19,9 @@ export { parseInstant, parseLocalDate, safeParseInstant, safeParseLocalDate, } f
14
19
  export { instantFromDate, instantFromEpochMilliseconds, instantFromEpochSeconds, } from "./core/instant.js";
15
20
  export { getRuntimeCapabilities } from "./runtime/capabilities.js";
16
21
  export { calendarDate } from "./core/calendar-date.js";
17
- export { localDate } from "./core/local-date.js";
22
+ export { localDate, createLocalDate } from "./core/local-date.js";
18
23
  export { localTime } from "./core/local-time.js";
19
24
  export { localDateTime } from "./core/local-date-time.js";
20
25
  export { dateRange } from "./core/range.js";
21
26
  export { ChroneraError, ChroneraParseError, ChroneraRangeError, ChroneraUnsupportedError, } from "./errors/index.js";
22
- export type { BuiltInCalendarId, CalendarPlugin, CalendarCapabilities, CalendarConversionMetadata, CalendarConversionResult, CalendarDate, CalendarId, ChroneraErrorCode, ChroneraConfig, ChroneraInstance, ChroneraIssue, Comparison, ConvertCalendarOptions, DateOrCalendarDate, DateRange, DayOfYearFields, Duration, EraId, FiscalFields, FiscalOptions, FormatDateBaseOptions, FormatDateInput, FormatDateOptions, FormatDateRangeOptions, FormatDateTimeOptions, FormatRelativeOptions, FormatTimeOptions, Instant, IntervalInclusivity, IsoWeekFields, LocalDate, LocalDateTime, LocalTime, LocaleId, MonthCode, NumberingSystemId, PatternFormatOptions, ParseInstantOptions, ParseLocalDateOptions, PresetName, QuarterNumber, ResolvedChroneraOptions, Rfc2822Options, RuntimeCapabilities, SafeParseResult, TimeZoneId, TimeOrDateTimeOrInstant, ZonedDateTime, } from "./public-types.js";
27
+ export type { BuiltInCalendarId, CalendarPlugin, CalendarCapabilities, CalendarConversionMetadata, CalendarConversionResult, CalendarDate, CalendarId, ChroneraErrorCode, ChroneraConfig, ChroneraInstance, ChroneraIssue, Comparison, ConvertCalendarOptions, DateOrCalendarDate, DateRange, DayOfYearFields, Duration, EraId, FiscalFields, FiscalOptions, FormatDateBaseOptions, FormatDateInput, FormatDateOptions, FormatDateRangeOptions, FormatDateTimeOptions, FormatInTimeZoneOptions, FormatRelativeOptions, FormatTimeOptions, Instant, IntervalInclusivity, IsoWeekFields, LocalDate, LocalDateTime, LocalTime, LocaleId, MonthCode, NumberingSystemId, PatternFormatOptions, ParseInstantOptions, ParseLocalDateOptions, PresetName, QuarterNumber, ResolvedChroneraOptions, Rfc2822Options, RuntimeCapabilities, SafeParseResult, SameTimeZoneOptions, TimeZoneId, TimeZoneOffsetFormat, TimeZoneOffsetInfo, TimeOrDateTimeOrInstant, ZonedDateTime, } from "./public-types.js";
package/dist/index.js CHANGED
@@ -2,7 +2,10 @@ export { createChronera } from "./create-chronera.js";
2
2
  export { compareInstants, compareLocalDates, sameAbsoluteDate, sameCalendarDate, } from "./operations/compare.js";
3
3
  export { getAbsoluteDay, isBefore, isAfter, isEqual, isSameDay, isBetween, isToday, addDays, subtractDays, addMonths, subtractMonths, addYears, subtractYears, diffInDays, startOfMonth, endOfMonth, startOfYear, endOfYear, } from "./operations/convenience.js";
4
4
  export { startOfDay, endOfDay, isPast, isFuture, addHours, subtractHours, addMinutes, subtractMinutes, addSeconds, subtractSeconds, } from "./operations/time-convenience.js";
5
- export { isWeekend, isWeekday, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
5
+ export { isWeekend, isWeekday, isBusinessDay, addBusinessDays, subtractBusinessDays, diffInBusinessDays, } from "./operations/business-days.js";
6
+ export { isPublicHoliday, getPublicHolidays, getHolidayDetails, } from "./operations/holidays.js";
7
+ export { registerHolidayCalendar, getHolidayCalendar, resolveAnnualHolidays, calculateEasterSunday, calculateGoodFriday, calculateEasterMonday, calculateAscensionDay, calculateWhitMonday, BUILT_IN_HOLIDAYS, thailandHolidays, japanHolidays, saudiArabiaHolidays, uaeHolidays, iranHolidays, taiwanHolidays, indiaHolidays, singaporeHolidays, unitedStatesHolidays, unitedKingdomHolidays, germanyHolidays, franceHolidays, australiaHolidays, chinaHolidays, hongKongHolidays, } from "./holidays/index.js";
8
+ export { formatInTimeZone, getTimeZoneOffset, isSameTimeZone, } from "./operations/timezone.js";
6
9
  export { convertCalendarDate } from "./operations/convert-calendar-date.js";
7
10
  export { daysInMonth, getCalendarCapabilities, isLeapYear, isValidCalendarDate, } from "./operations/validate.js";
8
11
  export { getIsoWeek, formatIsoWeek } from "./operations/iso-week.js";
@@ -14,7 +17,7 @@ export { parseInstant, parseLocalDate, safeParseInstant, safeParseLocalDate, } f
14
17
  export { instantFromDate, instantFromEpochMilliseconds, instantFromEpochSeconds, } from "./core/instant.js";
15
18
  export { getRuntimeCapabilities } from "./runtime/capabilities.js";
16
19
  export { calendarDate } from "./core/calendar-date.js";
17
- export { localDate } from "./core/local-date.js";
20
+ export { localDate, createLocalDate } from "./core/local-date.js";
18
21
  export { localTime } from "./core/local-time.js";
19
22
  export { localDateTime } from "./core/local-date-time.js";
20
23
  export { dateRange } from "./core/range.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,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AA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["export { createChronera } from \"./create-chronera.js\";\n\nexport {\n compareInstants,\n compareLocalDates,\n sameAbsoluteDate,\n sameCalendarDate,\n} from \"./operations/compare.js\";\n\nexport {\n getAbsoluteDay,\n isBefore,\n isAfter,\n isEqual,\n isSameDay,\n isBetween,\n isToday,\n addDays,\n subtractDays,\n addMonths,\n subtractMonths,\n addYears,\n subtractYears,\n diffInDays,\n startOfMonth,\n endOfMonth,\n startOfYear,\n endOfYear,\n} from \"./operations/convenience.js\";\n\nexport {\n startOfDay,\n endOfDay,\n isPast,\n isFuture,\n addHours,\n subtractHours,\n addMinutes,\n subtractMinutes,\n addSeconds,\n subtractSeconds,\n} from \"./operations/time-convenience.js\";\n\nexport {\n isWeekend,\n isWeekday,\n addBusinessDays,\n subtractBusinessDays,\n diffInBusinessDays,\n} from \"./operations/business-days.js\";\n\nexport { convertCalendarDate } from \"./operations/convert-calendar-date.js\";\n\nexport {\n daysInMonth,\n getCalendarCapabilities,\n isLeapYear,\n isValidCalendarDate,\n} from \"./operations/validate.js\";\n\nexport { getIsoWeek, formatIsoWeek } from \"./operations/iso-week.js\";\n\nexport {\n getDayOfYear,\n getDayOfYearWithRegistry,\n formatOrdinalDate,\n} from \"./operations/day-of-year.js\";\n\nexport {\n toJulianDayNumber,\n toModifiedJulianDay,\n localDateFromJulianDayNumber,\n localDateFromModifiedJulianDay,\n} from \"./operations/julian-day.js\";\n\nexport { getQuarter, getFiscalYear } from \"./operations/fiscal.js\";\n\nexport {\n formatDate,\n formatDateRange,\n formatDateTime,\n formatRelative,\n formatTime,\n formatWithPattern,\n formatRfc2822,\n formatJapaneseOfficialPreset,\n formatJapaneseOfficialWithWeekdayPreset,\n formatTaiwanOfficialPreset,\n formatThaiOfficialPreset,\n formatArabicGregorianPreset,\n formatArabicHijriPreset,\n formatChineseShortPreset,\n formatChineseStandardPreset,\n formatChineseWithWeekdayPreset,\n formatFrenchLongPreset,\n formatFrenchStandardPreset,\n formatFrenchWithWeekdayPreset,\n formatGermanDinStandardPreset,\n formatGermanLongPreset,\n formatGermanWithWeekdayPreset,\n formatJapaneseEraShortPreset,\n formatJapaneseSeirekiPreset,\n formatSpanishLongPreset,\n formatSpanishStandardPreset,\n formatSpanishWithWeekdayPreset,\n formatThaiShortDatePreset,\n formatThaiSlashDatePreset,\n formatUkLongPreset,\n formatUkStandardPreset,\n formatUkWithWeekdayPreset,\n formatUsLongPreset,\n formatUsStandardPreset,\n formatUsWithWeekdayPreset,\n} from \"./format/index.js\";\n\nexport {\n parseInstant,\n parseLocalDate,\n safeParseInstant,\n safeParseLocalDate,\n} from \"./parse/index.js\";\n\nexport {\n instantFromDate,\n instantFromEpochMilliseconds,\n instantFromEpochSeconds,\n} from \"./core/instant.js\";\n\nexport { getRuntimeCapabilities } from \"./runtime/capabilities.js\";\n\nexport { calendarDate } from \"./core/calendar-date.js\";\n\nexport { localDate } from \"./core/local-date.js\";\n\nexport { localTime } from \"./core/local-time.js\";\n\nexport { localDateTime } from \"./core/local-date-time.js\";\n\nexport { dateRange } from \"./core/range.js\";\n\nexport {\n ChroneraError,\n ChroneraParseError,\n ChroneraRangeError,\n ChroneraUnsupportedError,\n} from \"./errors/index.js\";\n\nexport type {\n BuiltInCalendarId,\n CalendarPlugin,\n CalendarCapabilities,\n CalendarConversionMetadata,\n CalendarConversionResult,\n CalendarDate,\n CalendarId,\n ChroneraErrorCode,\n ChroneraConfig,\n ChroneraInstance,\n ChroneraIssue,\n Comparison,\n ConvertCalendarOptions,\n DateOrCalendarDate,\n DateRange,\n DayOfYearFields,\n Duration,\n EraId,\n FiscalFields,\n FiscalOptions,\n FormatDateBaseOptions,\n FormatDateInput,\n FormatDateOptions,\n FormatDateRangeOptions,\n FormatDateTimeOptions,\n FormatRelativeOptions,\n FormatTimeOptions,\n Instant,\n IntervalInclusivity,\n IsoWeekFields,\n LocalDate,\n LocalDateTime,\n LocalTime,\n LocaleId,\n MonthCode,\n NumberingSystemId,\n PatternFormatOptions,\n ParseInstantOptions,\n ParseLocalDateOptions,\n PresetName,\n QuarterNumber,\n ResolvedChroneraOptions,\n Rfc2822Options,\n RuntimeCapabilities,\n SafeParseResult,\n TimeZoneId,\n TimeOrDateTimeOrInstant,\n ZonedDateTime,\n} from \"./public-types.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,QAAQ,EACR,OAAO,EACP,OAAO,EACP,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AClB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC","sourcesContent":["export { createChronera } from \"./create-chronera.js\";\n\nexport {\n compareInstants,\n compareLocalDates,\n sameAbsoluteDate,\n sameCalendarDate,\n} from \"./operations/compare.js\";\n\nexport {\n getAbsoluteDay,\n isBefore,\n isAfter,\n isEqual,\n isSameDay,\n isBetween,\n isToday,\n addDays,\n subtractDays,\n addMonths,\n subtractMonths,\n addYears,\n subtractYears,\n diffInDays,\n startOfMonth,\n endOfMonth,\n startOfYear,\n endOfYear,\n} from \"./operations/convenience.js\";\n\nexport {\n startOfDay,\n endOfDay,\n isPast,\n isFuture,\n addHours,\n subtractHours,\n addMinutes,\n subtractMinutes,\n addSeconds,\n subtractSeconds,\n} from \"./operations/time-convenience.js\";\n\nexport {\n isWeekend,\n isWeekday,\n isBusinessDay,\n addBusinessDays,\n subtractBusinessDays,\n diffInBusinessDays,\n} from \"./operations/business-days.js\";\n\nexport {\n isPublicHoliday,\n getPublicHolidays,\n getHolidayDetails,\n} from \"./operations/holidays.js\";\n\nexport {\n registerHolidayCalendar,\n getHolidayCalendar,\n resolveAnnualHolidays,\n calculateEasterSunday,\n calculateGoodFriday,\n calculateEasterMonday,\n calculateAscensionDay,\n calculateWhitMonday,\n BUILT_IN_HOLIDAYS,\n thailandHolidays,\n japanHolidays,\n saudiArabiaHolidays,\n uaeHolidays,\n iranHolidays,\n taiwanHolidays,\n indiaHolidays,\n singaporeHolidays,\n unitedStatesHolidays,\n unitedKingdomHolidays,\n germanyHolidays,\n franceHolidays,\n australiaHolidays,\n chinaHolidays,\n hongKongHolidays,\n} from \"./holidays/index.js\";\n\nexport type {\n CountryCode,\n PublicHoliday,\n HolidayCalendar,\n HolidayRule,\n HolidayOptions,\n ObservedRollRule,\n} from \"./holidays/types.js\";\n\nexport type { BusinessDaysOptions } from \"./operations/business-days.js\";\n\nexport {\n formatInTimeZone,\n getTimeZoneOffset,\n isSameTimeZone,\n} from \"./operations/timezone.js\";\n\nexport { convertCalendarDate } from \"./operations/convert-calendar-date.js\";\n\nexport {\n daysInMonth,\n getCalendarCapabilities,\n isLeapYear,\n isValidCalendarDate,\n} from \"./operations/validate.js\";\n\nexport { getIsoWeek, formatIsoWeek } from \"./operations/iso-week.js\";\n\nexport {\n getDayOfYear,\n getDayOfYearWithRegistry,\n formatOrdinalDate,\n} from \"./operations/day-of-year.js\";\n\nexport {\n toJulianDayNumber,\n toModifiedJulianDay,\n localDateFromJulianDayNumber,\n localDateFromModifiedJulianDay,\n} from \"./operations/julian-day.js\";\n\nexport { getQuarter, getFiscalYear } from \"./operations/fiscal.js\";\n\nexport {\n formatDate,\n formatDateRange,\n formatDateTime,\n formatRelative,\n formatTime,\n formatWithPattern,\n formatRfc2822,\n formatJapaneseOfficialPreset,\n formatJapaneseOfficialWithWeekdayPreset,\n formatTaiwanOfficialPreset,\n formatThaiOfficialPreset,\n formatArabicGregorianPreset,\n formatArabicHijriPreset,\n formatChineseShortPreset,\n formatChineseStandardPreset,\n formatChineseWithWeekdayPreset,\n formatFrenchLongPreset,\n formatFrenchStandardPreset,\n formatFrenchWithWeekdayPreset,\n formatGermanDinStandardPreset,\n formatGermanLongPreset,\n formatGermanWithWeekdayPreset,\n formatJapaneseEraShortPreset,\n formatJapaneseSeirekiPreset,\n formatSpanishLongPreset,\n formatSpanishStandardPreset,\n formatSpanishWithWeekdayPreset,\n formatThaiShortDatePreset,\n formatThaiSlashDatePreset,\n formatUkLongPreset,\n formatUkStandardPreset,\n formatUkWithWeekdayPreset,\n formatUsLongPreset,\n formatUsStandardPreset,\n formatUsWithWeekdayPreset,\n} from \"./format/index.js\";\n\nexport {\n parseInstant,\n parseLocalDate,\n safeParseInstant,\n safeParseLocalDate,\n} from \"./parse/index.js\";\n\nexport {\n instantFromDate,\n instantFromEpochMilliseconds,\n instantFromEpochSeconds,\n} from \"./core/instant.js\";\n\nexport { getRuntimeCapabilities } from \"./runtime/capabilities.js\";\n\nexport { calendarDate } from \"./core/calendar-date.js\";\n\nexport { localDate, createLocalDate } from \"./core/local-date.js\";\n\nexport { localTime } from \"./core/local-time.js\";\n\nexport { localDateTime } from \"./core/local-date-time.js\";\n\nexport { dateRange } from \"./core/range.js\";\n\nexport {\n ChroneraError,\n ChroneraParseError,\n ChroneraRangeError,\n ChroneraUnsupportedError,\n} from \"./errors/index.js\";\n\nexport type {\n BuiltInCalendarId,\n CalendarPlugin,\n CalendarCapabilities,\n CalendarConversionMetadata,\n CalendarConversionResult,\n CalendarDate,\n CalendarId,\n ChroneraErrorCode,\n ChroneraConfig,\n ChroneraInstance,\n ChroneraIssue,\n Comparison,\n ConvertCalendarOptions,\n DateOrCalendarDate,\n DateRange,\n DayOfYearFields,\n Duration,\n EraId,\n FiscalFields,\n FiscalOptions,\n FormatDateBaseOptions,\n FormatDateInput,\n FormatDateOptions,\n FormatDateRangeOptions,\n FormatDateTimeOptions,\n FormatInTimeZoneOptions,\n FormatRelativeOptions,\n FormatTimeOptions,\n Instant,\n IntervalInclusivity,\n IsoWeekFields,\n LocalDate,\n LocalDateTime,\n LocalTime,\n LocaleId,\n MonthCode,\n NumberingSystemId,\n PatternFormatOptions,\n ParseInstantOptions,\n ParseLocalDateOptions,\n PresetName,\n QuarterNumber,\n ResolvedChroneraOptions,\n Rfc2822Options,\n RuntimeCapabilities,\n SafeParseResult,\n SameTimeZoneOptions,\n TimeZoneId,\n TimeZoneOffsetFormat,\n TimeZoneOffsetInfo,\n TimeOrDateTimeOrInstant,\n ZonedDateTime,\n} from \"./public-types.js\";\n"]}
@@ -1,27 +1,43 @@
1
- import type { DateOrCalendarDate } from "../public-types.js";
1
+ import type { CountryCode, HolidayCalendar } from "../holidays/types.js";
2
+ import type { DateOrCalendarDate, LocalDate } from "../public-types.js";
2
3
  /**
3
- * Returns true if the specified date falls on a weekend (Saturday or Sunday).
4
- * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).
4
+ * Options for business days arithmetic and queries.
5
5
  */
6
- export declare function isWeekend(date: DateOrCalendarDate): boolean;
6
+ export interface BusinessDaysOptions {
7
+ /**
8
+ * Country code (e.g. "TH", "JP", "US") or custom HolidayCalendar or holiday date list or holiday predicate.
9
+ */
10
+ readonly holidays?: CountryCode | string | HolidayCalendar | readonly DateOrCalendarDate[] | ((date: LocalDate) => boolean);
11
+ /**
12
+ * Custom weekend days (defaults to [6, 7], or [4, 5] if country is Iran, etc.).
13
+ */
14
+ readonly weekendDays?: readonly number[];
15
+ }
7
16
  /**
8
- * Returns true if the specified date falls on a weekday (Monday through Friday).
9
- * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).
17
+ * Returns true if the specified date falls on a weekend.
18
+ * Supports custom weekend definitions per country (e.g. Thursday & Friday for Iran).
10
19
  */
11
- export declare function isWeekday(date: DateOrCalendarDate): boolean;
20
+ export declare function isWeekend(date: DateOrCalendarDate, options?: Pick<BusinessDaysOptions, "weekendDays" | "holidays">): boolean;
12
21
  /**
13
- * Adds business days to a LocalDate or CalendarDate, skipping Saturdays and Sundays.
22
+ * Returns true if the specified date falls on a weekday.
23
+ */
24
+ export declare function isWeekday(date: DateOrCalendarDate, options?: Pick<BusinessDaysOptions, "weekendDays" | "holidays">): boolean;
25
+ /**
26
+ * Returns true if the specified date is a business day (neither weekend nor public holiday).
27
+ */
28
+ export declare function isBusinessDay(date: DateOrCalendarDate, options?: BusinessDaysOptions): boolean;
29
+ /**
30
+ * Adds business days to a LocalDate or CalendarDate, skipping weekends and optionally public holidays.
14
31
  * Supports positive, negative, and zero day additions.
15
- * Uses O(1) mathematical week advancement for large intervals while preserving exact calendar semantics.
32
+ * Uses O(1) mathematical week advancement when no holidays are provided, or iterative evaluation with holiday constraints.
16
33
  */
17
- export declare function addBusinessDays<T extends DateOrCalendarDate>(date: T, amount: number): T;
34
+ export declare function addBusinessDays<T extends DateOrCalendarDate>(date: T, amount: number, options?: BusinessDaysOptions): T;
18
35
  /**
19
- * Subtracts business days from a LocalDate or CalendarDate, skipping weekends.
36
+ * Subtracts business days from a LocalDate or CalendarDate, skipping weekends and optional holidays.
20
37
  */
21
- export declare function subtractBusinessDays<T extends DateOrCalendarDate>(date: T, amount: number): T;
38
+ export declare function subtractBusinessDays<T extends DateOrCalendarDate>(date: T, amount: number, options?: BusinessDaysOptions): T;
22
39
  /**
23
40
  * Returns the signed count of business days between two dates (left - right).
24
41
  * Positive if left is after right, negative if left is before right, 0 if identical.
25
- * Works across all calendar systems with O(1) mathematical week acceleration.
26
42
  */
27
- export declare function diffInBusinessDays(left: DateOrCalendarDate, right: DateOrCalendarDate): number;
43
+ export declare function diffInBusinessDays(left: DateOrCalendarDate, right: DateOrCalendarDate, options?: BusinessDaysOptions): number;
@@ -1,28 +1,82 @@
1
1
  import { getIsoDayOfWeek } from "../core/iso-week.js";
2
+ import { localDate } from "../core/local-date.js";
3
+ import { gregorianFromAbsoluteDay } from "../calendar/gregory/absolute-day.js";
2
4
  import { ChroneraError } from "../errors/errors.js";
3
5
  import { addDays, getAbsoluteDay } from "./convenience.js";
6
+ import { isPublicHoliday } from "./holidays.js";
7
+ import { getHolidayCalendar } from "../holidays/registry.js";
4
8
  /**
5
- * Returns true if the specified date falls on a weekend (Saturday or Sunday).
6
- * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).
9
+ * Checks whether a given absolute day is a weekend according to options or country defaults.
7
10
  */
8
- export function isWeekend(date) {
9
- const abs = getAbsoluteDay(date);
11
+ function isWeekendForOptions(abs, options) {
10
12
  const dow = getIsoDayOfWeek(abs);
13
+ if (options?.weekendDays && options.weekendDays.length > 0) {
14
+ return options.weekendDays.includes(dow);
15
+ }
16
+ if (typeof options?.holidays === "string" ||
17
+ (typeof options?.holidays === "object" &&
18
+ options?.holidays !== null &&
19
+ "country" in options.holidays)) {
20
+ try {
21
+ const cal = getHolidayCalendar(options.holidays);
22
+ if (cal.defaultWeekendDays) {
23
+ return cal.defaultWeekendDays.includes(dow);
24
+ }
25
+ }
26
+ catch {
27
+ // Fallback to standard Saturday & Sunday
28
+ }
29
+ }
11
30
  return dow === 6 || dow === 7;
12
31
  }
13
32
  /**
14
- * Returns true if the specified date falls on a weekday (Monday through Friday).
15
- * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).
33
+ * Returns true if the specified absolute day is a non-working day (weekend or holiday).
34
+ */
35
+ function isNonWorkingDay(abs, options) {
36
+ if (isWeekendForOptions(abs, options)) {
37
+ return true;
38
+ }
39
+ const holidays = options?.holidays;
40
+ if (!holidays) {
41
+ return false;
42
+ }
43
+ const gFields = gregorianFromAbsoluteDay(abs);
44
+ const gDate = localDate(gFields.year, gFields.month, gFields.day);
45
+ if (typeof holidays === "function") {
46
+ return holidays(gDate);
47
+ }
48
+ if (typeof holidays === "string" || "rules" in holidays) {
49
+ return isPublicHoliday(gDate, holidays);
50
+ }
51
+ return holidays.some((hDate) => getAbsoluteDay(hDate) === abs);
52
+ }
53
+ /**
54
+ * Returns true if the specified date falls on a weekend.
55
+ * Supports custom weekend definitions per country (e.g. Thursday & Friday for Iran).
56
+ */
57
+ export function isWeekend(date, options) {
58
+ const abs = getAbsoluteDay(date);
59
+ return isWeekendForOptions(abs, options);
60
+ }
61
+ /**
62
+ * Returns true if the specified date falls on a weekday.
63
+ */
64
+ export function isWeekday(date, options) {
65
+ return !isWeekend(date, options);
66
+ }
67
+ /**
68
+ * Returns true if the specified date is a business day (neither weekend nor public holiday).
16
69
  */
17
- export function isWeekday(date) {
18
- return !isWeekend(date);
70
+ export function isBusinessDay(date, options) {
71
+ const abs = getAbsoluteDay(date);
72
+ return !isNonWorkingDay(abs, options);
19
73
  }
20
74
  /**
21
- * Adds business days to a LocalDate or CalendarDate, skipping Saturdays and Sundays.
75
+ * Adds business days to a LocalDate or CalendarDate, skipping weekends and optionally public holidays.
22
76
  * Supports positive, negative, and zero day additions.
23
- * Uses O(1) mathematical week advancement for large intervals while preserving exact calendar semantics.
77
+ * Uses O(1) mathematical week advancement when no holidays are provided, or iterative evaluation with holiday constraints.
24
78
  */
25
- export function addBusinessDays(date, amount) {
79
+ export function addBusinessDays(date, amount, options) {
26
80
  if (!Number.isFinite(amount)) {
27
81
  throw new ChroneraError("CHRONERA_OUT_OF_RANGE", "Amount must be a finite integer.");
28
82
  }
@@ -34,17 +88,31 @@ export function addBusinessDays(date, amount) {
34
88
  let currentAbs = startAbs;
35
89
  let remaining = intAmount;
36
90
  const step = remaining > 0 ? 1 : -1;
37
- while (remaining !== 0) {
38
- const currentDow = getIsoDayOfWeek(currentAbs);
39
- if (currentDow !== 6 && currentDow !== 7 && Math.abs(remaining) >= 5) {
40
- const fullWeeks = Math.trunc(remaining / 5);
41
- currentAbs += fullWeeks * 7;
42
- remaining %= 5;
91
+ // Fast-path: no holidays or custom weekends
92
+ const hasHolidays = Boolean(options?.holidays);
93
+ const hasCustomWeekends = Boolean(options?.weekendDays);
94
+ if (!hasHolidays && !hasCustomWeekends) {
95
+ while (remaining !== 0) {
96
+ const currentDow = getIsoDayOfWeek(currentAbs);
97
+ if (currentDow !== 6 && currentDow !== 7 && Math.abs(remaining) >= 5) {
98
+ const fullWeeks = Math.trunc(remaining / 5);
99
+ currentAbs += fullWeeks * 7;
100
+ remaining %= 5;
101
+ }
102
+ else {
103
+ currentAbs += step;
104
+ const dow = getIsoDayOfWeek(currentAbs);
105
+ if (dow !== 6 && dow !== 7) {
106
+ remaining -= step;
107
+ }
108
+ }
43
109
  }
44
- else {
110
+ }
111
+ else {
112
+ // Exact evaluation with holiday and custom weekend constraints
113
+ while (remaining !== 0) {
45
114
  currentAbs += step;
46
- const dow = getIsoDayOfWeek(currentAbs);
47
- if (dow !== 6 && dow !== 7) {
115
+ if (!isNonWorkingDay(currentAbs, options)) {
48
116
  remaining -= step;
49
117
  }
50
118
  }
@@ -53,39 +121,49 @@ export function addBusinessDays(date, amount) {
53
121
  return addDays(date, deltaDays);
54
122
  }
55
123
  /**
56
- * Subtracts business days from a LocalDate or CalendarDate, skipping weekends.
124
+ * Subtracts business days from a LocalDate or CalendarDate, skipping weekends and optional holidays.
57
125
  */
58
- export function subtractBusinessDays(date, amount) {
59
- return addBusinessDays(date, -amount);
126
+ export function subtractBusinessDays(date, amount, options) {
127
+ return addBusinessDays(date, -amount, options);
60
128
  }
61
129
  /**
62
130
  * Returns the signed count of business days between two dates (left - right).
63
131
  * Positive if left is after right, negative if left is before right, 0 if identical.
64
- * Works across all calendar systems with O(1) mathematical week acceleration.
65
132
  */
66
- export function diffInBusinessDays(left, right) {
133
+ export function diffInBusinessDays(left, right, options) {
67
134
  const absLeft = getAbsoluteDay(left);
68
135
  const absRight = getAbsoluteDay(right);
69
136
  if (absLeft === absRight) {
70
137
  return 0;
71
138
  }
72
139
  if (absLeft < absRight) {
73
- return -diffInBusinessDays(right, left);
140
+ return -diffInBusinessDays(right, left, options);
74
141
  }
75
142
  let count = 0;
76
143
  let current = absRight;
77
- // O(1) acceleration: any consecutive 7 calendar days contains exactly 5 business days
78
- const fullWeeks = Math.floor((absLeft - current) / 7);
79
- if (fullWeeks > 0) {
80
- count += fullWeeks * 5;
81
- current += fullWeeks * 7;
144
+ const hasHolidays = Boolean(options?.holidays);
145
+ const hasCustomWeekends = Boolean(options?.weekendDays);
146
+ if (!hasHolidays && !hasCustomWeekends) {
147
+ // Fast-path O(1) acceleration: any consecutive 7 calendar days contains exactly 5 business days
148
+ const fullWeeks = Math.floor((absLeft - current) / 7);
149
+ if (fullWeeks > 0) {
150
+ count += fullWeeks * 5;
151
+ current += fullWeeks * 7;
152
+ }
153
+ while (current < absLeft) {
154
+ current++;
155
+ const dow = getIsoDayOfWeek(current);
156
+ if (dow !== 6 && dow !== 7) {
157
+ count++;
158
+ }
159
+ }
82
160
  }
83
- // Step through remainder (at most 6 days)
84
- while (current < absLeft) {
85
- current++;
86
- const dow = getIsoDayOfWeek(current);
87
- if (dow !== 6 && dow !== 7) {
88
- count++;
161
+ else {
162
+ while (current < absLeft) {
163
+ current++;
164
+ if (!isNonWorkingDay(current, options)) {
165
+ count++;
166
+ }
89
167
  }
90
168
  }
91
169
  return count;
@@ -1 +1 @@
1
- {"version":3,"file":"business-days.js","sourceRoot":"","sources":["../../src/operations/business-days.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAO,EACP,MAAc;IAEd,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,aAAa,CACrB,uBAAuB,EACvB,kCAAkC,CACnC,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,UAAU,GAAG,QAAQ,CAAC;IAC1B,IAAI,SAAS,GAAG,SAAS,CAAC;IAC1B,MAAM,IAAI,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpC,OAAO,SAAS,KAAK,CAAC,EAA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IACd,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,sFAAsF;IACtF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,KAAK,IAAI,SAAS,GAAG,CAAC,CAAC;QACvB,OAAO,IAAI,SAAS,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,0CAA0C;IAC1C,OAAO,OAAO,GAAG,OAAO,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;QACV,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;YAC3B,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { getIsoDayOfWeek } from \"../core/iso-week.js\";\nimport { ChroneraError } from \"../errors/errors.js\";\nimport { addDays, getAbsoluteDay } from \"./convenience.js\";\n\nimport type { DateOrCalendarDate } from \"../public-types.js\";\n\n/**\n * Returns true if the specified date falls on a weekend (Saturday or Sunday).\n * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).\n */\nexport function isWeekend(date: DateOrCalendarDate): boolean {\n const abs = getAbsoluteDay(date);\n const dow = getIsoDayOfWeek(abs);\n return dow === 6 || dow === 7;\n}\n\n/**\n * Returns true if the specified date falls on a weekday (Monday through Friday).\n * Works across all calendars (Gregorian, Thai Buddhist, Japanese, Hijri, etc.).\n */\nexport function isWeekday(date: DateOrCalendarDate): boolean {\n return !isWeekend(date);\n}\n\n/**\n * Adds business days to a LocalDate or CalendarDate, skipping Saturdays and Sundays.\n * Supports positive, negative, and zero day additions.\n * Uses O(1) mathematical week advancement for large intervals while preserving exact calendar semantics.\n */\nexport function addBusinessDays<T extends DateOrCalendarDate>(\n date: T,\n amount: number,\n): T {\n if (!Number.isFinite(amount)) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n \"Amount must be a finite integer.\",\n );\n }\n\n const intAmount = Math.trunc(amount);\n if (intAmount === 0) {\n return date;\n }\n\n const startAbs = getAbsoluteDay(date);\n let currentAbs = startAbs;\n let remaining = intAmount;\n const step = remaining > 0 ? 1 : -1;\n\n while (remaining !== 0) {\n const currentDow = getIsoDayOfWeek(currentAbs);\n if (currentDow !== 6 && currentDow !== 7 && Math.abs(remaining) >= 5) {\n const fullWeeks = Math.trunc(remaining / 5);\n currentAbs += fullWeeks * 7;\n remaining %= 5;\n } else {\n currentAbs += step;\n const dow = getIsoDayOfWeek(currentAbs);\n if (dow !== 6 && dow !== 7) {\n remaining -= step;\n }\n }\n }\n\n const deltaDays = currentAbs - startAbs;\n return addDays(date, deltaDays);\n}\n\n/**\n * Subtracts business days from a LocalDate or CalendarDate, skipping weekends.\n */\nexport function subtractBusinessDays<T extends DateOrCalendarDate>(\n date: T,\n amount: number,\n): T {\n return addBusinessDays(date, -amount);\n}\n\n/**\n * Returns the signed count of business days between two dates (left - right).\n * Positive if left is after right, negative if left is before right, 0 if identical.\n * Works across all calendar systems with O(1) mathematical week acceleration.\n */\nexport function diffInBusinessDays(\n left: DateOrCalendarDate,\n right: DateOrCalendarDate,\n): number {\n const absLeft = getAbsoluteDay(left);\n const absRight = getAbsoluteDay(right);\n\n if (absLeft === absRight) {\n return 0;\n }\n\n if (absLeft < absRight) {\n return -diffInBusinessDays(right, left);\n }\n\n let count = 0;\n let current = absRight;\n\n // O(1) acceleration: any consecutive 7 calendar days contains exactly 5 business days\n const fullWeeks = Math.floor((absLeft - current) / 7);\n if (fullWeeks > 0) {\n count += fullWeeks * 5;\n current += fullWeeks * 7;\n }\n\n // Step through remainder (at most 6 days)\n while (current < absLeft) {\n current++;\n const dow = getIsoDayOfWeek(current);\n if (dow !== 6 && dow !== 7) {\n count++;\n }\n }\n\n return count;\n}\n"]}
1
+ {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AAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,GAAG,QAAQ,CAAC;IAEvB,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/C,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAExD,IAAI,CAAC,WAAW,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvC,gGAAgG;QAChG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,KAAK,IAAI,SAAS,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,SAAS,GAAG,CAAC,CAAC;QAC3B,CAAC;QAED,OAAO,OAAO,GAAG,OAAO,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;YACV,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;YACrC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;gBAC3B,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,OAAO,GAAG,OAAO,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;gBACvC,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { getIsoDayOfWeek } from \"../core/iso-week.js\";\nimport { localDate } from \"../core/local-date.js\";\nimport { gregorianFromAbsoluteDay } from \"../calendar/gregory/absolute-day.js\";\nimport { ChroneraError } from \"../errors/errors.js\";\nimport { addDays, getAbsoluteDay } from \"./convenience.js\";\nimport { isPublicHoliday } from \"./holidays.js\";\nimport { getHolidayCalendar } from \"../holidays/registry.js\";\n\nimport type { CountryCode, HolidayCalendar } from \"../holidays/types.js\";\nimport type { DateOrCalendarDate, LocalDate } from \"../public-types.js\";\n\n/**\n * Options for business days arithmetic and queries.\n */\nexport interface BusinessDaysOptions {\n /**\n * Country code (e.g. \"TH\", \"JP\", \"US\") or custom HolidayCalendar or holiday date list or holiday predicate.\n */\n readonly holidays?:\n | CountryCode\n | string\n | HolidayCalendar\n | readonly DateOrCalendarDate[]\n | ((date: LocalDate) => boolean);\n /**\n * Custom weekend days (defaults to [6, 7], or [4, 5] if country is Iran, etc.).\n */\n readonly weekendDays?: readonly number[];\n}\n\n/**\n * Checks whether a given absolute day is a weekend according to options or country defaults.\n */\nfunction isWeekendForOptions(\n abs: number,\n options?: BusinessDaysOptions,\n): boolean {\n const dow = getIsoDayOfWeek(abs);\n if (options?.weekendDays && options.weekendDays.length > 0) {\n return options.weekendDays.includes(dow);\n }\n\n if (\n typeof options?.holidays === \"string\" ||\n (typeof options?.holidays === \"object\" &&\n options?.holidays !== null &&\n \"country\" in options.holidays)\n ) {\n try {\n const cal = getHolidayCalendar(options.holidays);\n if (cal.defaultWeekendDays) {\n return cal.defaultWeekendDays.includes(dow);\n }\n } catch {\n // Fallback to standard Saturday & Sunday\n }\n }\n\n return dow === 6 || dow === 7;\n}\n\n/**\n * Returns true if the specified absolute day is a non-working day (weekend or holiday).\n */\nfunction isNonWorkingDay(abs: number, options?: BusinessDaysOptions): boolean {\n if (isWeekendForOptions(abs, options)) {\n return true;\n }\n\n const holidays = options?.holidays;\n if (!holidays) {\n return false;\n }\n\n const gFields = gregorianFromAbsoluteDay(abs);\n const gDate = localDate(gFields.year, gFields.month, gFields.day);\n\n if (typeof holidays === \"function\") {\n return holidays(gDate);\n }\n\n if (typeof holidays === \"string\" || \"rules\" in holidays) {\n return isPublicHoliday(gDate, holidays);\n }\n\n return holidays.some((hDate) => getAbsoluteDay(hDate) === abs);\n}\n\n/**\n * Returns true if the specified date falls on a weekend.\n * Supports custom weekend definitions per country (e.g. Thursday & Friday for Iran).\n */\nexport function isWeekend(\n date: DateOrCalendarDate,\n options?: Pick<BusinessDaysOptions, \"weekendDays\" | \"holidays\">,\n): boolean {\n const abs = getAbsoluteDay(date);\n return isWeekendForOptions(abs, options);\n}\n\n/**\n * Returns true if the specified date falls on a weekday.\n */\nexport function isWeekday(\n date: DateOrCalendarDate,\n options?: Pick<BusinessDaysOptions, \"weekendDays\" | \"holidays\">,\n): boolean {\n return !isWeekend(date, options);\n}\n\n/**\n * Returns true if the specified date is a business day (neither weekend nor public holiday).\n */\nexport function isBusinessDay(\n date: DateOrCalendarDate,\n options?: BusinessDaysOptions,\n): boolean {\n const abs = getAbsoluteDay(date);\n return !isNonWorkingDay(abs, options);\n}\n\n/**\n * Adds business days to a LocalDate or CalendarDate, skipping weekends and optionally public holidays.\n * Supports positive, negative, and zero day additions.\n * Uses O(1) mathematical week advancement when no holidays are provided, or iterative evaluation with holiday constraints.\n */\nexport function addBusinessDays<T extends DateOrCalendarDate>(\n date: T,\n amount: number,\n options?: BusinessDaysOptions,\n): T {\n if (!Number.isFinite(amount)) {\n throw new ChroneraError(\n \"CHRONERA_OUT_OF_RANGE\",\n \"Amount must be a finite integer.\",\n );\n }\n\n const intAmount = Math.trunc(amount);\n if (intAmount === 0) {\n return date;\n }\n\n const startAbs = getAbsoluteDay(date);\n let currentAbs = startAbs;\n let remaining = intAmount;\n const step = remaining > 0 ? 1 : -1;\n\n // Fast-path: no holidays or custom weekends\n const hasHolidays = Boolean(options?.holidays);\n const hasCustomWeekends = Boolean(options?.weekendDays);\n\n if (!hasHolidays && !hasCustomWeekends) {\n while (remaining !== 0) {\n const currentDow = getIsoDayOfWeek(currentAbs);\n if (currentDow !== 6 && currentDow !== 7 && Math.abs(remaining) >= 5) {\n const fullWeeks = Math.trunc(remaining / 5);\n currentAbs += fullWeeks * 7;\n remaining %= 5;\n } else {\n currentAbs += step;\n const dow = getIsoDayOfWeek(currentAbs);\n if (dow !== 6 && dow !== 7) {\n remaining -= step;\n }\n }\n }\n } else {\n // Exact evaluation with holiday and custom weekend constraints\n while (remaining !== 0) {\n currentAbs += step;\n if (!isNonWorkingDay(currentAbs, options)) {\n remaining -= step;\n }\n }\n }\n\n const deltaDays = currentAbs - startAbs;\n return addDays(date, deltaDays);\n}\n\n/**\n * Subtracts business days from a LocalDate or CalendarDate, skipping weekends and optional holidays.\n */\nexport function subtractBusinessDays<T extends DateOrCalendarDate>(\n date: T,\n amount: number,\n options?: BusinessDaysOptions,\n): T {\n return addBusinessDays(date, -amount, options);\n}\n\n/**\n * Returns the signed count of business days between two dates (left - right).\n * Positive if left is after right, negative if left is before right, 0 if identical.\n */\nexport function diffInBusinessDays(\n left: DateOrCalendarDate,\n right: DateOrCalendarDate,\n options?: BusinessDaysOptions,\n): number {\n const absLeft = getAbsoluteDay(left);\n const absRight = getAbsoluteDay(right);\n\n if (absLeft === absRight) {\n return 0;\n }\n\n if (absLeft < absRight) {\n return -diffInBusinessDays(right, left, options);\n }\n\n let count = 0;\n let current = absRight;\n\n const hasHolidays = Boolean(options?.holidays);\n const hasCustomWeekends = Boolean(options?.weekendDays);\n\n if (!hasHolidays && !hasCustomWeekends) {\n // Fast-path O(1) acceleration: any consecutive 7 calendar days contains exactly 5 business days\n const fullWeeks = Math.floor((absLeft - current) / 7);\n if (fullWeeks > 0) {\n count += fullWeeks * 5;\n current += fullWeeks * 7;\n }\n\n while (current < absLeft) {\n current++;\n const dow = getIsoDayOfWeek(current);\n if (dow !== 6 && dow !== 7) {\n count++;\n }\n }\n } else {\n while (current < absLeft) {\n current++;\n if (!isNonWorkingDay(current, options)) {\n count++;\n }\n }\n }\n\n return count;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { CountryCode, HolidayCalendar, HolidayOptions, PublicHoliday } from "../holidays/types.js";
2
+ import type { DateOrCalendarDate } from "../public-types.js";
3
+ /**
4
+ * Returns true if the specified date is an official public holiday in the given country.
5
+ * Supports both Gregorian LocalDate and any cultural CalendarDate (Thai Buddhist, Japanese Reiwa, Hijri, etc.).
6
+ */
7
+ export declare function isPublicHoliday(date: DateOrCalendarDate, country: CountryCode | string | HolidayCalendar, options?: HolidayOptions): boolean;
8
+ /**
9
+ * Returns all public holidays for a given year in the specified country.
10
+ */
11
+ export declare function getPublicHolidays(year: number, country: CountryCode | string | HolidayCalendar, options?: HolidayOptions): readonly PublicHoliday[];
12
+ /**
13
+ * Returns the public holiday details if the specified date is a holiday, or undefined otherwise.
14
+ */
15
+ export declare function getHolidayDetails(date: DateOrCalendarDate, country: CountryCode | string | HolidayCalendar, options?: HolidayOptions): PublicHoliday | undefined;
@@ -0,0 +1,36 @@
1
+ import { gregorianFromAbsoluteDay } from "../calendar/gregory/absolute-day.js";
2
+ import { localDate } from "../core/local-date.js";
3
+ import { getAbsoluteDay } from "./convenience.js";
4
+ import { resolveAnnualHolidays } from "../holidays/registry.js";
5
+ function toGregorianLocalDate(date) {
6
+ if (date.kind === "local-date") {
7
+ return date;
8
+ }
9
+ const abs = getAbsoluteDay(date);
10
+ const fields = gregorianFromAbsoluteDay(abs);
11
+ return localDate(fields.year, fields.month, fields.day);
12
+ }
13
+ /**
14
+ * Returns true if the specified date is an official public holiday in the given country.
15
+ * Supports both Gregorian LocalDate and any cultural CalendarDate (Thai Buddhist, Japanese Reiwa, Hijri, etc.).
16
+ */
17
+ export function isPublicHoliday(date, country, options) {
18
+ const gDate = toGregorianLocalDate(date);
19
+ const annualHolidays = resolveAnnualHolidays(country, gDate.year, options);
20
+ return annualHolidays.some((h) => h.date.month === gDate.month && h.date.day === gDate.day);
21
+ }
22
+ /**
23
+ * Returns all public holidays for a given year in the specified country.
24
+ */
25
+ export function getPublicHolidays(year, country, options) {
26
+ return resolveAnnualHolidays(country, year, options);
27
+ }
28
+ /**
29
+ * Returns the public holiday details if the specified date is a holiday, or undefined otherwise.
30
+ */
31
+ export function getHolidayDetails(date, country, options) {
32
+ const gDate = toGregorianLocalDate(date);
33
+ const annualHolidays = resolveAnnualHolidays(country, gDate.year, options);
34
+ return annualHolidays.find((h) => h.date.month === gDate.month && h.date.day === gDate.day);
35
+ }
36
+ //# sourceMappingURL=holidays.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holidays.js","sourceRoot":"","sources":["../../src/operations/holidays.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAUhE,SAAS,oBAAoB,CAAC,IAAwB;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC7C,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAwB,EACxB,OAA+C,EAC/C,OAAwB;IAExB,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE3E,OAAO,cAAc,CAAC,IAAI,CACxB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAChE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,OAA+C,EAC/C,OAAwB;IAExB,OAAO,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAwB,EACxB,OAA+C,EAC/C,OAAwB;IAExB,MAAM,KAAK,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,qBAAqB,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE3E,OAAO,cAAc,CAAC,IAAI,CACxB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAChE,CAAC;AACJ,CAAC","sourcesContent":["import { gregorianFromAbsoluteDay } from \"../calendar/gregory/absolute-day.js\";\nimport { localDate } from \"../core/local-date.js\";\nimport { getAbsoluteDay } from \"./convenience.js\";\nimport { resolveAnnualHolidays } from \"../holidays/registry.js\";\n\nimport type {\n CountryCode,\n HolidayCalendar,\n HolidayOptions,\n PublicHoliday,\n} from \"../holidays/types.js\";\nimport type { DateOrCalendarDate, LocalDate } from \"../public-types.js\";\n\nfunction toGregorianLocalDate(date: DateOrCalendarDate): LocalDate {\n if (date.kind === \"local-date\") {\n return date;\n }\n const abs = getAbsoluteDay(date);\n const fields = gregorianFromAbsoluteDay(abs);\n return localDate(fields.year, fields.month, fields.day);\n}\n\n/**\n * Returns true if the specified date is an official public holiday in the given country.\n * Supports both Gregorian LocalDate and any cultural CalendarDate (Thai Buddhist, Japanese Reiwa, Hijri, etc.).\n */\nexport function isPublicHoliday(\n date: DateOrCalendarDate,\n country: CountryCode | string | HolidayCalendar,\n options?: HolidayOptions,\n): boolean {\n const gDate = toGregorianLocalDate(date);\n const annualHolidays = resolveAnnualHolidays(country, gDate.year, options);\n\n return annualHolidays.some(\n (h) => h.date.month === gDate.month && h.date.day === gDate.day,\n );\n}\n\n/**\n * Returns all public holidays for a given year in the specified country.\n */\nexport function getPublicHolidays(\n year: number,\n country: CountryCode | string | HolidayCalendar,\n options?: HolidayOptions,\n): readonly PublicHoliday[] {\n return resolveAnnualHolidays(country, year, options);\n}\n\n/**\n * Returns the public holiday details if the specified date is a holiday, or undefined otherwise.\n */\nexport function getHolidayDetails(\n date: DateOrCalendarDate,\n country: CountryCode | string | HolidayCalendar,\n options?: HolidayOptions,\n): PublicHoliday | undefined {\n const gDate = toGregorianLocalDate(date);\n const annualHolidays = resolveAnnualHolidays(country, gDate.year, options);\n\n return annualHolidays.find(\n (h) => h.date.month === gDate.month && h.date.day === gDate.day,\n );\n}\n"]}