bizdays-toolkit 0.32.0 → 0.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,19 @@ Entries from 0.31.0 are in English. Earlier entries remain in Japanese (their **
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.32.2] - 2026-11-15
10
+
11
+ ### Fixed
12
+
13
+ - The option diagnostics reported an item as `redundant` (removing it does not change any result) although removing it made a day at the edge of the holiday provider's supported years throw `out-of-range`. A rule that looks at a neighbouring day (an `"after-holiday"` rule looking back for the day it was moved from, a rule for the day before or after a holiday, an nth-business-day-of-the-week rule) throws `out-of-range` when that day is outside the supported years. When another item decided the edge day first (an earlier recurring rule, a date in `closedDates` or `openDates`), the day was evaluated without an exception, the diagnostics reported that item as `redundant`, and removing it as suggested made the day throw. The diagnostics evaluated days outside the supported years as days without holidays and so did not see the exception. They now evaluate such a day as the calendar does and treat it as a day that cannot be judged, so the item is no longer reported. This applies with `outOfRangePolicy: "throw"` (the default); with `"ignore"` nothing throws and nothing changes. No result of a calendar or schedule changes
14
+ - As a consequence, an item that decides a day at the edge of the supported years is no longer reported as `redundant` even when it is redundant on every other day. For example, with the `jp` provider and an `"after-holiday"` rule for Mondays, a weekly Sunday rule that duplicates `closedWeekdays` is no longer reported, because removing it would make 1955-01-02 (the first Sunday of the supported years) throw; the same rule for Saturdays is still reported. With the `sg` provider and a rule for the day before a holiday, a weekly Friday rule that duplicates `closedWeekdays` is no longer reported, because of 2027-12-31
15
+
16
+ ## [0.32.1] - 2026-11-14
17
+
18
+ ### Fixed
19
+
20
+ - The option diagnostics reported an item as `redundant` (removing it does not change any result) although removing it made a day throw. This happened only with a holiday provider that returns holidays on more than 31 consecutive days and a `holidayOverlapPolicy: "after-holiday"` rule whose day cannot be moved past that run (the case that throws `holiday-run-too-long` since 0.32.0): when another item decided the first day after the run before the rule was reached (a date in `closedDates` or `openDates`, an annual date, or an earlier recurring rule), the calendar evaluated that day without an exception, the diagnostics reported that item as `redundant`, and removing it as suggested made the day throw `holiday-run-too-long`. The diagnostics now treat a day on which the evaluation throws `holiday-run-too-long` as a day that cannot be judged (an item is not reported as `redundant` when removing it changes whether a day can be judged), so such an item is no longer reported. A wrong diagnostic disappears; no result of a calendar or schedule changes, and the `warning` with code `holiday-run-too-long` is reported as before. The opposite direction remains and is documented (design decisions 31): the `"after-holiday"` rule that loses its day can itself be reported as `redundant`, and removing it makes the exception disappear
21
+
9
22
  ## [0.32.0] - 2026-11-14
10
23
 
11
24
  This minor version stops one silent loss of closed days, makes aliases of a time zone the same time zone on runtimes with Temporal, and makes one mistaken call a type error. Some code needs a check; see Migration.
@@ -1001,7 +1014,9 @@ This version rebuilds the `redundant` diagnostic so that the reported rules can
1001
1014
 
1002
1015
  - 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
1003
1016
 
1004
- [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.0...HEAD
1017
+ [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.2...HEAD
1018
+ [0.32.2]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.1...v0.32.2
1019
+ [0.32.1]: https://github.com/inohan77/bizdays-toolkit/compare/v0.32.0...v0.32.1
1005
1020
  [0.32.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.9...v0.32.0
1006
1021
  [0.31.9]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.8...v0.31.9
1007
1022
  [0.31.8]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.7...v0.31.8
@@ -3,7 +3,7 @@ import { compileCalendarOptions } from "./calendar.js";
3
3
  import { internalError, InternalError, describeValue, IssueCollector, rangeError, } from "./errors.js";
4
4
  import { isOptionsObject } from "./options.js";
5
5
  import { RENAMED_KEYS, RENAMED_VALUES } from "./renamed.js";
6
- import { compileScheduleOptions, createBasis, createHolidayLookup, createResolver, ignoreLostShift, lostShiftMessage, inPeriod, MAX_HOLIDAY_RUN, jpUsage, matchMonthDay, matchPattern, isHolidayBasedRule, resultIgnoresHolidays, } from "./schedule.js";
6
+ import { compileScheduleOptions, createBasis, createHolidayLookup, createResolver, lostShiftMessage, throwLostShift, inPeriod, MAX_HOLIDAY_RUN, jpUsage, matchMonthDay, matchPattern, isHolidayBasedRule, resultIgnoresHolidays, } from "./schedule.js";
7
7
  function editDistance(a, b) {
8
8
  const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)));
9
9
  for (let i = 1; i <= a.length; i++) {
@@ -51,8 +51,19 @@ const MIN_DAY = toDayNumber("1000-01-01");
51
51
  const MAX_DAY = toDayNumber("9999-12-31");
52
52
  const MAX_WINDOW_YEARS = 200;
53
53
  const MAX_DATE_RULE_DAYS = 366 * MAX_WINDOW_YEARS;
54
+ const isLostShift = (error) => error?.code === "holiday-run-too-long";
54
55
  const atCalendarEdge = (n, error) => (n < MIN_DAY + MAX_HOLIDAY_RUN || n > MAX_DAY - MAX_HOLIDAY_RUN) &&
55
56
  error?.code === "out-of-range";
57
+ const PROVIDER_EDGE_DAYS = 367;
58
+ const atEdge = (n, error, window) => {
59
+ if (atCalendarEdge(n, error))
60
+ return true;
61
+ if (error?.code !== "out-of-range" || !window)
62
+ return false;
63
+ const first = window.ranges[0].from;
64
+ const last = window.ranges[window.ranges.length - 1].to;
65
+ return n < first + PROVIDER_EDGE_DAYS || n > last - PROVIDER_EDGE_DAYS;
66
+ };
56
67
  function openEndedDays(from, days) {
57
68
  const lo = Math.max(from, MIN_DAY);
58
69
  const hi = Math.min(from + days - 1, MAX_DAY);
@@ -450,7 +461,7 @@ function checkLostShifts(c, compiled, lookup, window) {
450
461
  resolve(fromDayNumber(n), false);
451
462
  }
452
463
  catch (error) {
453
- if (!atCalendarEdge(n, error))
464
+ if (!atEdge(n, error, window))
454
465
  throw error;
455
466
  }
456
467
  }
@@ -482,7 +493,6 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
482
493
  return;
483
494
  const lookup = createHolidayLookup({
484
495
  ...source,
485
- outOfRangePolicy: "ignore",
486
496
  unconfirmedHolidayPolicy: "accept",
487
497
  });
488
498
  const basis = createBasis(compiled, lookup);
@@ -701,14 +711,14 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
701
711
  }
702
712
  }
703
713
  if (isCalendar && window && !dates.some((r) => r.value === true)) {
704
- const resolve = createResolver(without(compiled, null, true), lookup, ignoreLostShift);
714
+ const resolve = createResolver(without(compiled, null, true), lookup, throwLostShift);
705
715
  let found = false;
706
716
  eachDay(window, (n) => {
707
717
  try {
708
718
  found = resolve(fromDayNumber(n)).day.value === true;
709
719
  }
710
720
  catch (error) {
711
- if (!atCalendarEdge(n, error))
721
+ if (!atEdge(n, error, window) && !isLostShift(error))
712
722
  throw error;
713
723
  found = false;
714
724
  }
@@ -759,7 +769,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
759
769
  };
760
770
  };
761
771
  const redundant = (rule, base, days, original) => {
762
- const resolve = createResolver(without(base, rule, false), lookup, ignoreLostShift);
772
+ const resolve = createResolver(without(base, rule, false), lookup, throwLostShift);
763
773
  for (const n of days) {
764
774
  let value;
765
775
  try {
@@ -788,7 +798,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
788
798
  });
789
799
  const judgeDate = (rule) => {
790
800
  const base = current(true);
791
- const resolve = createResolver(base, lookup, ignoreLostShift);
801
+ const resolve = createResolver(base, lookup, throwLostShift);
792
802
  const decided = [];
793
803
  const span = [];
794
804
  let checked = 0;
@@ -829,7 +839,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
829
839
  const decidedIn = (rule) => {
830
840
  if (!decided && window) {
831
841
  const map = new Map(candidates.map((r) => [r, new Set()]));
832
- const resolveNow = createResolver(current(counting.length > 0), lookup, ignoreLostShift);
842
+ const resolveNow = createResolver(current(counting.length > 0), lookup, throwLostShift);
833
843
  eachDay(window, (n) => {
834
844
  let by;
835
845
  try {
@@ -849,7 +859,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
849
859
  const refresh = (affected) => {
850
860
  if (!decided)
851
861
  return;
852
- const resolveNow = createResolver(current(counting.length > 0), lookup, ignoreLostShift);
862
+ const resolveNow = createResolver(current(counting.length > 0), lookup, throwLostShift);
853
863
  for (const n of affected) {
854
864
  if (!inWindow(n) || unjudged.has(n))
855
865
  continue;
@@ -860,7 +870,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
860
870
  decided.get(by)?.add(n);
861
871
  }
862
872
  };
863
- const originalNow = originalOf(createResolver(current(counting.length > 0), lookup, ignoreLostShift));
873
+ const originalNow = originalOf(createResolver(current(counting.length > 0), lookup, throwLostShift));
864
874
  const unitsOf = new Map();
865
875
  const annualUnits = (rule) => {
866
876
  const known = unitsOf.get(rule);
@@ -923,7 +933,7 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
923
933
  }
924
934
  if (reported.size === 0)
925
935
  return;
926
- const resolveFinal = createResolver(current(true), lookup, ignoreLostShift);
936
+ const resolveFinal = createResolver(current(true), lookup, throwLostShift);
927
937
  const relatedOf = (days) => {
928
938
  const paths = new Set();
929
939
  for (const n of days) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bizdays-toolkit",
3
- "version": "0.32.0",
3
+ "version": "0.32.2",
4
4
  "description": "Holidays, business-day calendar and day-by-day schedules (e.g. store hours) with time zone support. Japanese holidays verified against the Cabinet Office data; UK bank holidays (England, Wales, Scotland, Northern Ireland) verified against GOV.UK and The Gazette; French public holidays (metropole, Alsace-Moselle) verified against data.gouv.fr; Singapore public holidays verified against data.gov.sg. / 祝日と営業日のカレンダー(タイムゾーン対応・日本の祝日は内閣府、英国の bank holidays は GOV.UK と The Gazette、フランスの祝日は data.gouv.fr、シンガポールの祝日は data.gov.sg のデータで全日照合)",
5
5
  "keywords": [
6
6
  "bank-holidays",