bizdays-toolkit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,11 @@
9
9
  * 内閣府の CSV で検証している。それより後の年は confirmed: false
10
10
  */
11
11
  import type { Holiday } from "../core/types.ts";
12
- /** 日本の祝日・休日の種別 */
13
- export type JapaneseHolidayKind =
12
+ /**
13
+ * 日本の祝日・休日の種別(既知の値)。
14
+ * @public
15
+ */
16
+ export type KnownJapaneseHolidayKind =
14
17
  /** 国民の祝日 */
15
18
  "national"
16
19
  /** 振替休日 */
@@ -19,18 +22,24 @@ export type JapaneseHolidayKind =
19
22
  | "citizens"
20
23
  /** 皇室行事などによる特例の休日 */
21
24
  | "special";
22
- /** 対応年 */
25
+ /**
26
+ * 日本の祝日・休日の種別。将来の版で値が増えることがあるので、分岐では「その他」も扱うこと。
27
+ * すべての値を網羅したことを型で確かめたい場合は KnownJapaneseHolidayKind を使う。
28
+ * @public
29
+ */
30
+ export type JapaneseHolidayKind = KnownJapaneseHolidayKind | (string & {});
31
+ /** @internal 対応年 */
23
32
  export declare const SUPPORTED_YEARS: Readonly<{
24
33
  from: 1955;
25
34
  to: 2099;
26
35
  }>;
27
- /** 春分・秋分の日が官報で確定している最後の年 */
36
+ /** @internal 春分・秋分の日が官報で確定している最後の年 */
28
37
  export declare const CONFIRMED_THROUGH = 2027;
29
- /** 反映済みの官報の年月(2027 年の春分・秋分の日の公表) */
38
+ /** @internal 反映済みの官報の年月(2027 年の春分・秋分の日の公表) */
30
39
  export declare const DATA_VERSION = "2026-02";
31
- /** 春分日(3 月の日) */
40
+ /** @internal 春分日(3 月の日) */
32
41
  export declare function vernalEquinoxDay(year: number): number;
33
- /** 秋分日(9 月の日) */
42
+ /** @internal 秋分日(9 月の日) */
34
43
  export declare function autumnalEquinoxDay(year: number): number;
35
- /** その年の祝日・休日(日付順) */
44
+ /** @internal その年の祝日・休日(日付順) */
36
45
  export declare function computeJapaneseHolidays(year: number): Holiday<JapaneseHolidayKind>[];
package/dist/jp/rules.js CHANGED
@@ -9,11 +9,12 @@
9
9
  * 内閣府の CSV で検証している。それより後の年は confirmed: false
10
10
  */
11
11
  import { addDays, formatDate, nthWeekdayOfMonth, weekdayOf, } from "../core/date.js";
12
- /** 対応年 */
12
+ import { rangeError } from "../core/errors.js";
13
+ /** @internal 対応年 */
13
14
  export const SUPPORTED_YEARS = Object.freeze({ from: 1955, to: 2099 });
14
- /** 春分・秋分の日が官報で確定している最後の年 */
15
+ /** @internal 春分・秋分の日が官報で確定している最後の年 */
15
16
  export const CONFIRMED_THROUGH = 2027;
16
- /** 反映済みの官報の年月(2027 年の春分・秋分の日の公表) */
17
+ /** @internal 反映済みの官報の年月(2027 年の春分・秋分の日の公表) */
17
18
  export const DATA_VERSION = "2026-02";
18
19
  const SUBSTITUTE_START = "1973-04-12";
19
20
  const SUBSTITUTE_2007 = "2007-01-01";
@@ -37,14 +38,14 @@ const SPECIAL_DAYS = [
37
38
  ];
38
39
  // 近似式の int() は 0 方向への切り捨て。1979 年以前は (year - 1983) / 4 が負になるため
39
40
  // Math.floor ではなく Math.trunc を使う(floor だと 1 日ずれる年がある)
40
- /** 春分日(3 月の日) */
41
+ /** @internal 春分日(3 月の日) */
41
42
  export function vernalEquinoxDay(year) {
42
43
  if (year <= 1979) {
43
44
  return Math.floor(20.8357 + 0.242194 * (year - 1980) - Math.trunc((year - 1983) / 4));
44
45
  }
45
46
  return Math.floor(20.8431 + 0.242194 * (year - 1980) - Math.floor((year - 1980) / 4));
46
47
  }
47
- /** 秋分日(9 月の日) */
48
+ /** @internal 秋分日(9 月の日) */
48
49
  export function autumnalEquinoxDay(year) {
49
50
  if (year <= 1979) {
50
51
  return Math.floor(23.2588 + 0.242194 * (year - 1980) - Math.trunc((year - 1983) / 4));
@@ -118,10 +119,10 @@ function baseHolidays(y) {
118
119
  }
119
120
  return list.sort((a, b) => (a.date < b.date ? -1 : 1));
120
121
  }
121
- /** その年の祝日・休日(日付順) */
122
+ /** @internal その年の祝日・休日(日付順) */
122
123
  export function computeJapaneseHolidays(year) {
123
124
  if (!Number.isInteger(year) || year < SUPPORTED_YEARS.from || year > SUPPORTED_YEARS.to) {
124
- throw new RangeError(`Japanese holidays are supported for ${SUPPORTED_YEARS.from}-${SUPPORTED_YEARS.to}; requested ${year}`);
125
+ throw rangeError("out-of-range", `Japanese holidays are supported for ${SUPPORTED_YEARS.from}-${SUPPORTED_YEARS.to}; requested ${year}`);
125
126
  }
126
127
  const base = baseHolidays(year);
127
128
  const byDate = new Map(base.map((e) => [e.date, e]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bizdays-toolkit",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
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. / 祝日と営業日のカレンダー(タイムゾーン対応・日本の祝日は内閣府データで全日照合)",
5
5
  "keywords": [
6
6
  "bizdays",
@@ -46,12 +46,14 @@
46
46
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
47
47
  "typecheck": "tsc --noEmit",
48
48
  "test": "node --test \"test/**/*.test.ts\"",
49
+ "test:tz": "node scripts/test-tz.ts",
49
50
  "fmt": "oxfmt",
50
51
  "fmt:check": "oxfmt --check",
51
- "check": "pnpm typecheck && pnpm test && pnpm build && pnpm fmt:check && node scripts/check-package.ts",
52
+ "check": "pnpm typecheck && pnpm test && pnpm test:tz && pnpm build && pnpm fmt:check && node scripts/check-package.ts && node scripts/check-size.ts && node scripts/api-report.ts",
52
53
  "verify:cao": "node scripts/verify-cao.ts",
53
54
  "prepublishOnly": "pnpm check",
54
- "release-notes": "node scripts/release-notes.ts"
55
+ "release-notes": "node scripts/release-notes.ts",
56
+ "api:update": "pnpm build && node scripts/api-report.ts --update"
55
57
  },
56
58
  "devDependencies": {
57
59
  "@types/node": "24.19.2",