bizdays-toolkit 0.30.1 → 0.30.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
@@ -4,6 +4,31 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.30.2] - 2026-10-30
8
+
9
+ 0.30.0・0.30.1 の改名の後始末の続きの版です。新しい設定・関数・診断コードはありません。公開物の `.js` の挙動が変わるのは Fixed の 1 つ(診断の結果)で、カレンダー・スケジュールの判定の結果は変わりません。
10
+
11
+ ### Fixed
12
+
13
+ - 診断: 日本の提供元だけの設定で、`"regular"` と旧名の `"national"` の同じ規則(祝日・祝日の翌日・祝前日の規則)が `shadowed` にならず、両方が `redundant` と出ていた。0.30.1 の退行で、`RELEASING.md` の互換性の約束(診断の結果は増えるだけ)から外れていた。0.30.0 と同じく、後の規則を `shadowed`(`relatedPath` は前の規則)として出す。ID `"JP"` の提供元が種別 `"national"` の祝日を返す設定では、意味が一致しないので同じものとして比べない。和集合では今までどおり `redundant` で見つかる。パッチで出す根拠は `docs/decisions.md` の 55 番(この版で、パッチ版で入った退行も対象にした)
14
+
15
+ ### Changed
16
+
17
+ - `docs/migration.md` の 0.30.0: 日本の提供元とほかの提供元を合わせた設定の `kinds` の `"regular"` が、0.30.0 から日本の国民の祝日にも当たることを「返す値」の注 2 に書いた(`"regular"` を検索する手順と、0.22.x と同じ結果にする書き方)。旧名を使っていない設定なので診断も `migrate…` も知らせず、0.30.0 の節の「移行」にも欠けていた。冒頭の検索の案内に、`withSubstituteDays` の呼び出しの `name:` を足した
18
+ - 0.30.1 の節の補足: 冒頭の「`.js` の挙動が変わるのは Fixed の 1 つだけ」は誤りだった。ほかに、`migrate…` が和集合で `"national"` を書き換えなくなったこと(Changed に記載。0.30.0 の約束に戻す修正なので、本来は Fixed)と、上の診断の退行も `.js` の挙動の変化だった
19
+ - ガイド(英日): 書き換えた設定を診断にかけ、`deprecated-option` が残っていないことを確かめる手順と例を足した(和集合の `"national"` は `migrate…` が書き換えない)。`shadowed` と `redundant` は規則を 1 つずつ外したときの判定で、複数の規則が出たら 1 つ外すたびに診断をやり直すことを足した
20
+ - 和集合の `"national"` の `deprecated-option` の長いメッセージを、作成時ではなく診断のときに組み立てるようにした。診断が返すメッセージは変わらない(作成時は警告を使わないので、ルートのバンドルから文を外した)
21
+ - README(英日)の版の固定の例を、具体的な版から `"x.y.z"` にした。minify + gzip のサイズを測り直した(ルート 13.0 → 12.9 KB、日本込み 14.7 → 14.6 KB、フランス込み・シンガポール込み 13.9 → 13.8 KB)
22
+ - ソースのコメントとテストで、`"national"` の扱いの根拠を 55 番としていたのを 54 番に直した
23
+ - `docs/decisions.md`: 54 番に 0.30.2 の追記(返す値の改名は「改名は結果を変えない」の例外であること、規則どうしの診断の項を実際の挙動に合わせた)を足し、55 番の対象を「直前の版(マイナー版・パッチ版)」に改め、56 番(同じ設定の結果を前の版と CI で比べる)を足した。旧名を本文に持つ 14・16・36・43・44 番に、0.30.0 の改名の追記を足した。`RELEASING.md`: パッチの区分を「直前の版」に改め、互換性の約束の診断の項に前の版の結果は新しい版でも返すことを、品質の確認に決定の文書の旧名と返す値の改名の確かめ方を足した
24
+
25
+ ### 開発
26
+
27
+ - CI に `result-compare` ジョブを足した(`scripts/result-compare.ts`)。種で決まる設定の集まりと過去の退行を再現する固定の設定を、公開済みの前の版と今回の `dist` に渡し、カレンダー(直接・合成・スケジュールから)とスケジュールの結果を 1 日ずつ比べ、診断は前の版の結果がすべて含まれることを確かめる。意図した差分は `etc/result-changes.json` に特徴・版・出典を書いたものだけを許す。0.30.x の間は 0.22.2 とも旧名の設定で比べる。公開済みの版どうしで確かめると、0.22.2 → 0.30.0 で和集合の `"national"` の退行を、0.30.0 → 0.30.1 で上の診断の退行を検出する
28
+ - `scripts/check-names.ts`: 前の版を動かす `scripts/result-compare.ts` を、旧名の検査(C14)の対象から外した
29
+ - `test/national-union.test.ts` に、日本の提供元だけの設定の `shadowed` の確認を足した
30
+ - サイズ(gzip): ルート 18,054 → 17,997(測定 17,997)、`./jp` 20,288 → 20,226(測定 20,226)、`./diagnose` 24,492 → 24,753(測定 24,753)。上限は変えていない
31
+
7
32
  ## [0.30.1] - 2026-10-30
8
33
 
9
34
  0.30.0 の改名の後始末の版です。新しい設定・関数・診断コードはありません。公開物の `.js` の挙動が変わるのは Fixed の 1 つだけです。
@@ -729,7 +754,8 @@
729
754
 
730
755
  - 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
731
756
 
732
- [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.30.1...HEAD
757
+ [Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.30.2...HEAD
758
+ [0.30.2]: https://github.com/inohan77/bizdays-toolkit/compare/v0.30.1...v0.30.2
733
759
  [0.30.1]: https://github.com/inohan77/bizdays-toolkit/compare/v0.30.0...v0.30.1
734
760
  [0.30.0]: https://github.com/inohan77/bizdays-toolkit/compare/v0.22.2...v0.30.0
735
761
  [0.22.2]: https://github.com/inohan77/bizdays-toolkit/compare/v0.22.1...v0.22.2
package/README.md CHANGED
@@ -24,7 +24,7 @@ A business-day calendar that combines public holidays with company or store clos
24
24
  - **Recurring rules**: "closed on the 3rd Wednesday", "every other Wednesday", "stocktaking on the last day of the month", "closed on Mondays, moved to the next non-holiday when Monday is a holiday", "the day after (or before) a holiday", "the last weekday before a bank holiday", shift cycles such as four days on and two days off, each with its own behaviour on holidays and an optional effective period
25
25
  - **Day-by-day values and combined calendars**: store hours that change by weekday, holiday and date; a business-day calendar made from such a schedule; and the days on which all (or any) of several calendars are open
26
26
  - **Option diagnostics**: `bizdays-toolkit/diagnose` lists rules that never apply, rules that are shadowed or redundant, rules that have ended, typos in option names and options with no business day at all, without throwing. One line in a test keeps options honest
27
- - **Lightweight, zero dependencies, time-zone safe**: about 13.0 KB min+gzip (about 14.7 KB with Japanese holidays, about 15.1 KB with UK bank holidays, about 13.9 KB with French holidays, about 13.9 KB with Singapore holidays; measured for 0.30.1). Standard JavaScript and `Intl` only, ESM with bundled types; tested on Node.js, Chrome, Firefox, Edge, Safari, Cloudflare Workers, Bun and Deno. Instants such as `Date` are converted to a civil date in the calendar's time zone before evaluation
27
+ - **Lightweight, zero dependencies, time-zone safe**: about 12.9 KB min+gzip (about 14.6 KB with Japanese holidays, about 15.1 KB with UK bank holidays, about 13.8 KB with French holidays, about 13.8 KB with Singapore holidays; measured for 0.30.2). Standard JavaScript and `Intl` only, ESM with bundled types; tested on Node.js, Chrome, Firefox, Edge, Safari, Cloudflare Workers, Bun and Deno. Instants such as `Date` are converted to a civil date in the calendar's time zone before evaluation
28
28
  - **Extensible to other countries and regions**: holiday providers are pluggable through the `HolidayProvider` interface, and `bizdays-toolkit/provider` exposes the calendar arithmetic (nth weekday of a month, Easter, substitute days for holidays on a weekend) that most countries' holidays are built from
29
29
 
30
30
  ## Installation
@@ -132,7 +132,7 @@ A holiday provider is an object with `id`, `timeZone`, `supportedYears` and `hol
132
132
  Versioning follows [Semantic Versioning](https://semver.org/). See [RELEASING.md](https://github.com/inohan77/bizdays-toolkit/blob/main/RELEASING.md) (Japanese) for details.
133
133
 
134
134
  - Official data updates (new, moved and one-off holidays by law, Official Gazette or proclamation, fixed equinox days in Japan, newly published years on GOV.UK, changes to the French Labour Code, newly gazetted years and revised dates in Singapore) are released as **patch** versions, so they reach you with either `^` or `~`
135
- - To freeze the holiday results, pin an exact version (for example `"bizdays-toolkit": "0.21.3"`)
135
+ - To freeze the holiday results, pin an exact version (for example `"bizdays-toolkit": "x.y.z"`)
136
136
  - The reflected data is shown by the provider's `dataVersion` (for Japan, the year and month of the Official Gazette reflected; for the UK, France and Singapore, the year and month of the GOV.UK, data.gouv.fr or data.gov.sg data reflected) and `confirmedThrough` (`jp.dataVersion`, `england.confirmedThrough` and so on). The module-level constants `dataVersion` and `confirmedThrough` in `bizdays-toolkit/jp` and `bizdays-toolkit/uk` are deprecated since 0.12.0 and will be removed in 1.0.0
137
137
  - Before 1.0.0, minor versions may contain breaking changes. What you need to change when moving between minor versions is listed in the [migration guide](https://github.com/inohan77/bizdays-toolkit/blob/main/docs/migration.md) (Japanese) and in the "移行" (migration) part of each version in the CHANGELOG
138
138
  - Decision reasons (`reason`), holiday kinds (`kind`), error codes and diagnostic codes may gain values in future versions. When you branch on their values, handle "anything else" too (see "互換性の約束", the compatibility promise, in [RELEASING.md](https://github.com/inohan77/bizdays-toolkit/blob/main/RELEASING.md))
@@ -333,6 +333,24 @@ function analyze(c, compiled, isCalendar) {
333
333
  return found;
334
334
  };
335
335
  const setCovers = (a, b) => a === null || (b !== null && [...b].every((v) => a.has(v)));
336
+ const renamedKind = RENAMED_VALUES.find((x) => x.key === "kinds");
337
+ let nationalAsRegular;
338
+ const kindsOf = (r) => {
339
+ if (!r.nationalOfJp || r.kinds === null)
340
+ return r.kinds;
341
+ if (nationalAsRegular === undefined) {
342
+ let found = false;
343
+ if (window && jpUsage(source) === "only") {
344
+ eachDay(window, (n) => (found = holidayOfSafe(fromDayNumber(n))?.kind === renamedKind.from));
345
+ nationalAsRegular = !found;
346
+ }
347
+ else
348
+ nationalAsRegular = false;
349
+ }
350
+ return nationalAsRegular
351
+ ? new Set([...r.kinds].map((k) => (k === renamedKind.from ? renamedKind.to : k)))
352
+ : r.kinds;
353
+ };
336
354
  const sameSkip = (a, b) => a.skipWeekdays === null
337
355
  ? b.skipWeekdays === null
338
356
  : b.skipWeekdays !== null &&
@@ -394,14 +412,14 @@ function analyze(c, compiled, isCalendar) {
394
412
  sameSkip(r, rule) &&
395
413
  (rule.holiday
396
414
  ? r.holiday &&
397
- setCovers(r.kinds, rule.kinds) &&
415
+ setCovers(kindsOf(r), kindsOf(rule)) &&
398
416
  setCovers(r.keys, rule.keys) &&
399
417
  setCovers(r.weekdays, rule.weekdays) &&
400
418
  setCovers(r.months, rule.months)
401
419
  : rule.dayAfterHoliday || rule.dayBeforeHoliday
402
420
  ? r.dayAfterHoliday === rule.dayAfterHoliday &&
403
421
  r.dayBeforeHoliday === rule.dayBeforeHoliday &&
404
- setCovers(r.kinds, rule.kinds) &&
422
+ setCovers(kindsOf(r), kindsOf(rule)) &&
405
423
  setCovers(r.keys, rule.keys) &&
406
424
  setCovers(r.weekdays, rule.weekdays) &&
407
425
  setCovers(r.months, rule.months)
@@ -544,7 +562,11 @@ function run(c, compiled, isCalendar, asOf) {
544
562
  c.error(code === "out-of-range" ? "out-of-range" : "invalid-provider-data", "holidayProvider", error instanceof Error ? error.message : String(error));
545
563
  }
546
564
  }
547
- return Object.freeze(c.issues.map(({ unknownKey, knownKeys, ...issue }) => {
565
+ return Object.freeze(c.issues.map(({ unknownKey, knownKeys, nationalInUnion, ...issue }) => {
566
+ if (nationalInUnion) {
567
+ const { from, to } = RENAMED_VALUES.find((r) => r.key === "kinds");
568
+ issue.message += `; here it matches Japan's "${to}" and other providers' "${from}" holidays. From 1.0.0 it is an invalid-option with a "JP" provider: wrap the Japanese provider and rename your own "${from}" kind (see the migration guide)`;
569
+ }
548
570
  const suggestion = unknownKey === undefined || knownKeys === undefined
549
571
  ? undefined
550
572
  : closestKey(unknownKey, knownKeys);
@@ -74,6 +74,8 @@ export interface Issue {
74
74
  /** unknown-option の知らないキーと既知のキー(診断で候補を挙げるため。結果には出さない) */
75
75
  readonly unknownKey?: string;
76
76
  readonly knownKeys?: readonly string[];
77
+ /** 和集合の設定の kinds の "national"(診断で、当てている祝日と 1.0.0 での扱いを添えるため。結果には出さない) */
78
+ readonly nationalInUnion?: true;
77
79
  }
78
80
  /** @internal 問題を集める */
79
81
  export declare class IssueCollector {
@@ -23,7 +23,7 @@ export interface RenamedValue {
23
23
  }
24
24
  /**
25
25
  * @internal 改名した値の表(0.30.0)。kinds の "national" は、ID が "JP" の祝日の提供元を使う設定でだけ扱いを変える。
26
- * 作成と診断は値を読み替えずに知らせ(schedule.ts の reportNational)、migrate… は日本の提供元だけの設定で書き換える(docs/decisions.md の 55 番)
26
+ * 作成と診断は値を読み替えずに知らせ(schedule.ts の reportNational)、migrate… は日本の提供元だけの設定で書き換える(docs/decisions.md の 54 番)
27
27
  */
28
28
  export declare const RENAMED_VALUES: readonly RenamedValue[];
29
29
  /** @internal 改名を見つけたときの扱い(作成・診断は記録して読み替える。合成などの記録先がない設定は読み替えるだけ) */
@@ -657,7 +657,7 @@ export interface RecurringRuleCompiled<Value> extends CompiledPeriod {
657
657
  readonly holiday: boolean;
658
658
  /** 祝日・祝日の翌日・祝前日の規則で絞る種別(null はすべての祝日) */
659
659
  readonly kinds: ReadonlySet<string> | null;
660
- /** kinds の旧名 "national" を、日本の提供元が返した "regular" の祝日にも当てるか(docs/decisions.md の 55 番) */
660
+ /** kinds の旧名 "national" を、日本の提供元が返した "regular" の祝日にも当てるか(docs/decisions.md の 54 番) */
661
661
  readonly nationalOfJp: boolean;
662
662
  /** 祝日・祝日の翌日・祝前日の規則で絞る識別子(null はすべての祝日) */
663
663
  readonly keys: ReadonlySet<string> | null;
@@ -673,10 +673,13 @@ function reportNational(c, path, kinds, mixed) {
673
673
  if (v !== from)
674
674
  return;
675
675
  found = true;
676
- c.warning("deprecated-option", `${path}[${i}]`, `"${from}" was renamed to "${to}" in 0.30.0` +
677
- (mixed
678
- ? `; here it matches Japan's "${to}" and other providers' "${from}" holidays. From 1.0.0 it is an invalid-option with a "JP" provider: wrap the Japanese provider and rename your own "${from}" kind (see the migration guide)`
679
- : ""));
676
+ c.issues.push({
677
+ severity: "warning",
678
+ code: "deprecated-option",
679
+ path: `${path}[${i}]`,
680
+ message: `"${from}" was renamed to "${to}" in 0.30.0`,
681
+ ...(mixed ? { nationalInUnion: true } : {}),
682
+ });
680
683
  });
681
684
  return found;
682
685
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bizdays-toolkit",
3
- "version": "0.30.1",
3
+ "version": "0.30.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",