bizdays-toolkit 0.31.6 → 0.31.8
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 +33 -1
- package/README.md +1 -1
- package/dist/core/calendar.d.ts +1 -1
- package/dist/core/calendar.js +6 -6
- package/dist/core/diagnose.d.ts +4 -1
- package/dist/core/errors.d.ts +8 -2
- package/dist/core/input.d.ts +2 -1
- package/dist/core/input.js +6 -3
- package/dist/core/migrate.js +2 -2
- package/dist/core/month.js +1 -3
- package/dist/core/schedule.d.ts +1 -1
- package/dist/core/schedule.js +25 -9
- package/dist/core/types.d.ts +3 -2
- package/dist/fr/rules.d.ts +1 -1
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,36 @@ Entries from 0.31.0 are in English. Earlier entries remain in Japanese (their **
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.31.8] - 2026-11-13
|
|
10
|
+
|
|
11
|
+
This version fixes one input that was silently accepted and corrects type descriptions and documents. Results of calls that were written correctly do not change.
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- A Temporal-like date-time whose `hour` was `null`, a string or another value that is not a number (such as `{ year: 2026, month: 12, day: 28, hour: "15", minute: 30 }`) was read as a date without a time, so `civilOf` returned `time: null` and a check such as `open <= time` was silently false. It now throws `invalid-time`, as `minute: null` does since 0.31.7 (design decisions 6). A Temporal-like value with `minute` but without `hour` is still read as a date. If you build the value from a form or a database, convert `hour` to a number first
|
|
16
|
+
- Type descriptions: `KnownErrorCode` now says that `no-business-day` also covers an nth business day that the month does not have and a calendar's closing month without its own period, and that `time-zone-conflict` also covers calendars combined with `combineCalendars` and the basis calendar of a schedule's nth-business-day rule (where the fix is to make them with the same time zone, not to set `timeZone`). `HolidayProvider` now describes long runs of holidays as below
|
|
17
|
+
- Documentation: the provider guide, the description of `HolidayProvider` and the design decisions (24) said that within a run of holidays longer than 31 days, rules for the day before or after a holiday do not match and `"after-holiday"` rules are not moved. In fact rules for the day before or after a holiday match the day before and the day after a run of any length, and an `"after-holiday"` rule is not moved only when its own day is more than 31 days before the first day after the run. The documents now say so; results are unchanged
|
|
18
|
+
- Documentation: the guide listed 2008 and 2059 as the years when two French holidays fall on the same day; Ascension Day also falls on May 8 in 2070, 2081 and 2092. The English README said that years after a provider's supported range are an error; years before it are too. The provider guide said that the four exceptional keys keep a word the rule would drop; `new-year` drops the possessive "s" as well. The design decisions (1, 3, 9) now list every case of `out-of-range`, describe `invalid-input` as a value in none of the accepted forms, and describe the functions that fix an argument of another by what they are rather than by name. Results are unchanged
|
|
19
|
+
|
|
20
|
+
## [0.31.7] - 2026-11-12
|
|
21
|
+
|
|
22
|
+
This version makes three kinds of options that were silently accepted throw, as the design decisions (6, 8) promise, gives a code to the remaining exceptions without one, and corrects documents. Options that were written correctly give the same results as before. Options that write both a single date and a range in one entry, write `null` in one of seven options, or have a hole in an array now throw; each item below says how to rewrite them.
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- An entry of `closedDates`, `openDates` and `closedAnnualDates` (and of a schedule's `dates` and `annualDates`) with both a single date (`date`) and a range (`from`/`to`), such as `{ date: "12-31", from: "12-29", to: "01-03" }`, was accepted and used only `date` (the diagnostics reported `from` and `to` as unknown options). It now throws `invalid-option` ("cannot have both"), and the diagnostics return it as an `error`, as the design decisions (8) say for conflicting options. Keep the form you mean and remove the other; an explicit `undefined` is still the same as leaving the key out
|
|
27
|
+
- `null` in seven options was silently replaced with the default, while `null` in every other option threw: `holidayPolicy` and `searchDayLimit` of `createCalendar`, `searchDayLimit` of `combineCalendars` and `createCalendarFromSchedule`, `outOfRangePolicy`, `unconfirmedHolidayPolicy`, and `holidayOverlapPolicy` of a recurring rule. They now throw `invalid-option` like other values the types do not accept, and the diagnostics return it as an `error`; the minute of a Temporal-like date-time (`minute: null`) now throws `invalid-time` instead of reading as 0. The design decisions (6) now say that `null` is not the same as leaving an option out (only `undefined` is; a schedule's `value: null` is still a value). If you wrote `null`, remove the key or write `undefined`
|
|
28
|
+
- A hole in an array (`[a, , b]`) was skipped in the options (`closedDates`, `openDates`, `closedAnnualDates`, the rules, `closedWeekdays`, `months`, `nth`, `weekdays`, `skipWeekdays` and the like, and a list of holiday providers), so a date or a rule left out of the array was silently lost, and `combineCalendars` with a hole threw `time-zone-conflict` instead of `invalid-argument`. A hole is now checked like an explicit `undefined` element and throws the same code; the design decisions (6) now say so. A hole in a schedule's `weekdayValues` is still the value `undefined`. If you build arrays by index, fill every element
|
|
29
|
+
- `monthOf` read only a string with exactly three hyphen-separated parts as a date, so a date-time string with an offset (such as `"2026-11-05T10:00-05:00"`) or `"2026-1-1-1"` threw `invalid-month`, while `closingPeriod` threw `invalid-date` for the same string (0.31.6). `monthOf` now reads strings the same way (three or more parts are a date); the design decisions (8) now list it. Valid months and dates give the same results
|
|
30
|
+
- The minute of a Temporal-like date-time that cannot be turned into a string (such as an array with a symbol) threw a `TypeError` without a `code` while building the message. It now throws `invalid-time`
|
|
31
|
+
- `diagnoseSchedule` did not report unknown keys inside the object of `holidayPolicy` (such as `{ value: null, sameAS: 0 }`, a typo of `sameAs`), although the design decisions (8) say that typos are found as `unknown-option`. It now reports them; the results are unchanged. The design decisions (31) now say that adding such a check where it was missing is a fix, not a new kind of diagnostic
|
|
32
|
+
- Type descriptions: `Diagnostic.relatedPath` now also describes `redundant` (the rule that decides instead) and `counting-basis` (the weekday rule that the count leaves out). `toInstant` and `instantOf` now say that the offset from UTC is used to the minute (in a period whose offset is not a whole number of minutes, such as local mean time or Liberia until 1972, the result can be up to 59 seconds off). The first sentence of `createCalendarFromSchedule` now ends with a full stop
|
|
33
|
+
- Documentation: the guide says the same about `toInstant`, and the guide and the design decisions (31) now say that the 28 years scanned by the diagnostics cover every combination of weekday and date only when they do not cross a year such as 2100 (which holds within 1901–2099); a rule with an open-ended effective period starting after 2072 can be reported as `never-matches` when it matches only in a later leap year. Results are unchanged
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- The npm keywords now also include `public-holidays`, `timezone` and `typescript`
|
|
38
|
+
|
|
9
39
|
## [0.31.6] - 2026-11-12
|
|
10
40
|
|
|
11
41
|
This version fixes option diagnostics that returned an `error` for options that can be created, exceptions without a `code`, and the code for malformed strings in `closingPeriod`, and corrects documents. Results of calls that already succeeded do not change; some calls that threw an exception without a `code` now throw one with a `code`, and a calendar's `closingPeriod` now reports a malformed month string as `invalid-month`.
|
|
@@ -929,7 +959,9 @@ This version rebuilds the `redundant` diagnostic so that the reported rules can
|
|
|
929
959
|
|
|
930
960
|
- 日本: 2026 年 2 月の官報(2027 年の春分・秋分の日)まで反映(`dataVersion: "2026-02"`、`confirmedThrough: 2027`)
|
|
931
961
|
|
|
932
|
-
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.
|
|
962
|
+
[Unreleased]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.8...HEAD
|
|
963
|
+
[0.31.8]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.7...v0.31.8
|
|
964
|
+
[0.31.7]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.6...v0.31.7
|
|
933
965
|
[0.31.6]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.5...v0.31.6
|
|
934
966
|
[0.31.5]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.4...v0.31.5
|
|
935
967
|
[0.31.4]: https://github.com/inohan77/bizdays-toolkit/compare/v0.31.3...v0.31.4
|
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ The [guide](https://github.com/inohan77/bizdays-toolkit/blob/main/docs/guide.md)
|
|
|
68
68
|
| `metropole`, `alsaceMoselle` | `bizdays-toolkit/fr` | `Europe/Paris` | 2000–2099 | data.gouv.fr "Jours fériés en France" |
|
|
69
69
|
| `sg` | `bizdays-toolkit/sg` | `Asia/Singapore` | 2020–2027 | data.gov.sg (Ministry of Manpower) |
|
|
70
70
|
|
|
71
|
-
Each holiday carries its date, name (and English name), `kind` (such as `regular`, `substitute` and `special`; the values differ by country) and `confirmed` (whether the date is officially fixed; the Japanese equinox days and UK bank holidays after the last published year are predictions). Years
|
|
71
|
+
Each holiday carries its date, name (and English name), `kind` (such as `regular`, `substitute` and `special`; the values differ by country) and `confirmed` (whether the date is officially fixed; the Japanese equinox days and UK bank holidays after the last published year are predictions). Years outside the supported range are an error unless `outOfRangePolicy: "ignore"` is set, and `unconfirmedHolidayPolicy: "throw"` stops any result that would depend on a predicted holiday. Details: [Bundled holiday providers](https://github.com/inohan77/bizdays-toolkit/blob/main/docs/guide.md#bundled-holiday-providers), [Unconfirmed holidays](https://github.com/inohan77/bizdays-toolkit/blob/main/docs/guide.md#unconfirmed-holidays).
|
|
72
72
|
|
|
73
73
|
### Business-day calendars and recurring rules
|
|
74
74
|
|
package/dist/core/calendar.d.ts
CHANGED
|
@@ -321,7 +321,7 @@ export interface CalendarFromScheduleOptions {
|
|
|
321
321
|
readonly maxSearchDays?: number;
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
|
-
* スケジュール(createSchedule)から営業日カレンダーを作る。isOpen が true
|
|
324
|
+
* スケジュール(createSchedule)から営業日カレンダーを作る。isOpen が true を返す値の日を営業日とする。
|
|
325
325
|
* isOpen は boolean を返す関数にする(boolean でない値を返すと code: "invalid-argument" の RangeError。作成時に曜日の値と
|
|
326
326
|
* holidayPolicy: { value } の値で呼んで確かめ、ほかの値の日は判定したときに確かめる)。
|
|
327
327
|
* 営業時間表のような日ごとの値が設定の正本で、営業日の計算(加減算・調整・期日など)も同じ設定から行いたいときに使う
|
package/dist/core/calendar.js
CHANGED
|
@@ -37,7 +37,7 @@ export function compileCalendarOptions(c, options) {
|
|
|
37
37
|
c.error("invalid-option", "closedWeekdays", "must be an array");
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
rawWeekdays.forEach((w, i) => {
|
|
40
|
+
Array.from(rawWeekdays).forEach((w, i) => {
|
|
41
41
|
if (isWeekday(w))
|
|
42
42
|
closedWeekdays.add(w);
|
|
43
43
|
else
|
|
@@ -45,11 +45,11 @@ export function compileCalendarOptions(c, options) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
const holidayPolicy = o["holidayPolicy"]
|
|
48
|
+
const holidayPolicy = o["holidayPolicy"] === undefined ? "closed" : o["holidayPolicy"];
|
|
49
49
|
if (holidayPolicy !== "closed" && holidayPolicy !== "open" && holidayPolicy !== "ignore") {
|
|
50
50
|
c.error("invalid-option", "holidayPolicy", 'must be "closed", "open" or "ignore"');
|
|
51
51
|
}
|
|
52
|
-
const searchDayLimit = o["searchDayLimit"]
|
|
52
|
+
const searchDayLimit = o["searchDayLimit"] === undefined ? 3660 : o["searchDayLimit"];
|
|
53
53
|
if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
|
|
54
54
|
c.error("invalid-option", "searchDayLimit", "must be a positive integer");
|
|
55
55
|
}
|
|
@@ -345,7 +345,7 @@ export function combineCalendars(calendars, options) {
|
|
|
345
345
|
if (!Array.isArray(calendars) || calendars.length < 2) {
|
|
346
346
|
throw rangeError("invalid-argument", "calendars must be an array of two or more calendars");
|
|
347
347
|
}
|
|
348
|
-
calendars.forEach((c, i) => {
|
|
348
|
+
Array.from(calendars).forEach((c, i) => {
|
|
349
349
|
if (!isCalendarLike(c))
|
|
350
350
|
throw rangeError("invalid-argument", `calendars[${i}] is not a calendar`);
|
|
351
351
|
if (calendars.indexOf(c) !== i) {
|
|
@@ -357,7 +357,7 @@ export function combineCalendars(calendars, options) {
|
|
|
357
357
|
if (mode !== "all" && mode !== "any") {
|
|
358
358
|
throw rangeError("invalid-option", 'open must be "all" or "any"');
|
|
359
359
|
}
|
|
360
|
-
const searchDayLimit = (o["searchDayLimit"]
|
|
360
|
+
const searchDayLimit = (o["searchDayLimit"] === undefined ? 3660 : o["searchDayLimit"]);
|
|
361
361
|
if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
|
|
362
362
|
throw rangeError("invalid-option", "searchDayLimit must be a positive integer");
|
|
363
363
|
}
|
|
@@ -435,7 +435,7 @@ export function createCalendarFromSchedule(schedule, isOpen, options) {
|
|
|
435
435
|
throw rangeError("invalid-argument", "isOpen must be a function (value) => boolean");
|
|
436
436
|
}
|
|
437
437
|
const o = optionsObject(options, "createCalendarFromSchedule options", (v) => renameKeys("throw", ["fromSchedule"], "", v), false, "invalid-option");
|
|
438
|
-
const searchDayLimit = (o["searchDayLimit"]
|
|
438
|
+
const searchDayLimit = (o["searchDayLimit"] === undefined ? 3660 : o["searchDayLimit"]);
|
|
439
439
|
if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
|
|
440
440
|
throw rangeError("invalid-option", "searchDayLimit must be a positive integer");
|
|
441
441
|
}
|
package/dist/core/diagnose.d.ts
CHANGED
|
@@ -64,7 +64,10 @@ export interface Diagnostic {
|
|
|
64
64
|
/** 設定の中の位置(例: "closedRecurringRules[1]"・"closedDates[0].date")。設定全体なら "" */
|
|
65
65
|
readonly path: string;
|
|
66
66
|
readonly message: string;
|
|
67
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* 関係する別の位置。shadowed では覆っている先の規則、redundant では取り除いたときに代わりに決める規則(1 つに定まる
|
|
69
|
+
* ときだけ)、counting-basis では数え方に入らない曜日の規則、out-of-range では祝日の提供元
|
|
70
|
+
*/
|
|
68
71
|
readonly relatedPath?: string;
|
|
69
72
|
}
|
|
70
73
|
/**
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -30,7 +30,10 @@ export type KnownErrorCode =
|
|
|
30
30
|
| "invalid-argument"
|
|
31
31
|
/** 設定の誤り。設定は営業日カレンダー・スケジュールを作る関数が検証するオブジェクトで、オブジェクトでないことも含む(decisions.md の 8 番) */
|
|
32
32
|
| "invalid-option"
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* 同じタイムゾーンでなければならないものが食い違う(1 つの設定の祝日の提供元どうしで、timeZone の指定がない。
|
|
35
|
+
* 合成するカレンダーどうし。スケジュールと、第 n 営業日の規則の数える基準のカレンダー)
|
|
36
|
+
*/
|
|
34
37
|
| "time-zone-conflict"
|
|
35
38
|
/**
|
|
36
39
|
* 対応している年の範囲の外(提供元の対応年、日付の計算や瞬間の変換が 1000〜9999 年の外に出た、祝日の一覧に渡した年が
|
|
@@ -43,7 +46,10 @@ export type KnownErrorCode =
|
|
|
43
46
|
| "invalid-provider"
|
|
44
47
|
/** 祝日の提供元が返したデータの誤り */
|
|
45
48
|
| "invalid-provider-data"
|
|
46
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* 営業日が見つからない(探索が searchDayLimit 日を超えた、月の営業日が第 n 営業日の n に足りない、カレンダーの締めの月に
|
|
51
|
+
* 固有の期間がない)
|
|
52
|
+
*/
|
|
47
53
|
| "no-business-day"
|
|
48
54
|
/** searchDayLimit の日数のうちに休業日が見つからない(nextClosedDay・previousClosedDay) */
|
|
49
55
|
| "no-closed-day";
|
package/dist/core/input.d.ts
CHANGED
|
@@ -81,7 +81,8 @@ export declare function toDateTimeParts(input: DateInput, timeZone: string): Civ
|
|
|
81
81
|
/**
|
|
82
82
|
* 暦日と時刻("HH:mm" または "HH:mm:ss")から、タイムゾーンでのその瞬間を Date で返す(civilOf・toDateTimeParts の逆向き)。
|
|
83
83
|
* 夏時間の切り替えで存在しない時刻は、飛んだ分だけ後ろの瞬間(英国の 3 月の 01:30 は 02:30 BST)、2 回ある時刻は先のほう
|
|
84
|
-
* (Temporal の disambiguation: "compatible"
|
|
84
|
+
* (Temporal の disambiguation: "compatible" と同じ)。時差は分の精度で扱う(時差が分の倍数でない時期、たとえば標準時の
|
|
85
|
+
* 制定より前の地方平均時やリベリアの 1972 年までは、結果が最大 59 秒ずれ、秒を付けた時刻は civilOf で同じ分に戻らないことがある)。
|
|
85
86
|
* @public
|
|
86
87
|
*/
|
|
87
88
|
export declare function toInstant(date: DateString, time: string, timeZone: string): Date;
|
package/dist/core/input.js
CHANGED
|
@@ -64,7 +64,7 @@ function wallTime(hour, minute) {
|
|
|
64
64
|
!Number.isInteger(minute) ||
|
|
65
65
|
minute < 0 ||
|
|
66
66
|
minute > 59) {
|
|
67
|
-
const two = (v) => String(v).padStart(2, "0");
|
|
67
|
+
const two = (v) => typeof v === "number" ? String(v).padStart(2, "0") : describeValue(v);
|
|
68
68
|
throw rangeError("invalid-time", `Invalid time: ${two(hour)}:${two(minute)}`);
|
|
69
69
|
}
|
|
70
70
|
return hour * 60 + minute;
|
|
@@ -120,8 +120,11 @@ export function toCivil(input, timeZone) {
|
|
|
120
120
|
throw rangeError("invalid-date", `Invalid date: year must be an integer from 1000 to 9999: ${describeValue(input.year)}`);
|
|
121
121
|
}
|
|
122
122
|
const date = formatDate(input.year, input.month, input.day);
|
|
123
|
-
if (
|
|
124
|
-
return {
|
|
123
|
+
if (input.hour !== undefined) {
|
|
124
|
+
return {
|
|
125
|
+
date,
|
|
126
|
+
minutes: wallTime(input.hour, input.minute === undefined ? 0 : input.minute),
|
|
127
|
+
};
|
|
125
128
|
}
|
|
126
129
|
return { date, minutes: null };
|
|
127
130
|
}
|
package/dist/core/migrate.js
CHANGED
|
@@ -20,8 +20,8 @@ function clone(v) {
|
|
|
20
20
|
}
|
|
21
21
|
const join = (path, key) => (path ? `${path}.${key}` : key);
|
|
22
22
|
function onlyJp(options) {
|
|
23
|
-
const raw = options["holidayProvider"]
|
|
24
|
-
const list = raw === undefined ? [] : Array.isArray(raw) ? raw : [raw];
|
|
23
|
+
const raw = options["holidayProvider"] === undefined ? options["holidays"] : options["holidayProvider"];
|
|
24
|
+
const list = raw === undefined ? [] : Array.isArray(raw) ? Array.from(raw) : [raw];
|
|
25
25
|
return (list.length > 0 &&
|
|
26
26
|
list.every((p) => typeof p === "object" && p !== null && p.id === "JP"));
|
|
27
27
|
}
|
package/dist/core/month.js
CHANGED
|
@@ -29,9 +29,7 @@ export function monthOf(input, offset = 0) {
|
|
|
29
29
|
if (!Number.isInteger(offset)) {
|
|
30
30
|
throw rangeError("invalid-argument", `offset must be an integer: ${describeValue(offset)}`);
|
|
31
31
|
}
|
|
32
|
-
const base = typeof input === "string" && input
|
|
33
|
-
? parseDate(input)
|
|
34
|
-
: parseMonth(input);
|
|
32
|
+
const base = typeof input === "string" && readsAsDate(input) ? parseDate(input) : parseMonth(input);
|
|
35
33
|
return formatMonth(shiftMonth(base, offset));
|
|
36
34
|
}
|
|
37
35
|
export function closingMonth(date, closingDayOfMonth) {
|
package/dist/core/schedule.d.ts
CHANGED
|
@@ -551,7 +551,7 @@ export interface HolidayLookup<Kind extends string = string> {
|
|
|
551
551
|
civilOf(input: DateInput): CivilDateTimeParts;
|
|
552
552
|
/**
|
|
553
553
|
* 暦日 "YYYY-MM-DD" と時刻("HH:mm" または "HH:mm:ss")から、タイムゾーンでのその瞬間を Date で返す(civilOf の逆向き)。
|
|
554
|
-
* 夏時間で存在しない時刻は飛んだ分だけ後ろに、2
|
|
554
|
+
* 夏時間で存在しない時刻は飛んだ分だけ後ろに、2 回ある時刻は先のほう。時差は分の精度で扱う(toInstant と同じ)
|
|
555
555
|
*/
|
|
556
556
|
instantOf(date: DateString, time: string): Date;
|
|
557
557
|
/** 今日の日付(タイムゾーン) */
|
package/dist/core/schedule.js
CHANGED
|
@@ -73,7 +73,7 @@ export function compileDateRules(c, path, entries, valueOf, allowString, valueKe
|
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
75
75
|
const rules = [];
|
|
76
|
-
entries.forEach((raw, i) => {
|
|
76
|
+
Array.from(entries).forEach((raw, i) => {
|
|
77
77
|
const p = `${path}[${i}]`;
|
|
78
78
|
const entry = allowString && typeof raw === "string" ? { date: raw } : raw;
|
|
79
79
|
if (!isObject(entry)) {
|
|
@@ -83,6 +83,10 @@ export function compileDateRules(c, path, entries, valueOf, allowString, valueKe
|
|
|
83
83
|
const got = valueOf(entry, p);
|
|
84
84
|
const name = checkName(c, p, entry["name"]);
|
|
85
85
|
const defined = withoutUndefined(entry, DATE_SHAPE_KEYS);
|
|
86
|
+
if ("date" in defined && ("from" in defined || "to" in defined)) {
|
|
87
|
+
c.error("invalid-option", p, 'cannot have both "date" and "from"/"to"');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
86
90
|
if ("date" in defined) {
|
|
87
91
|
checkUnknownKeys(c, p, defined, ["date", "name", ...(valueKey ? ["value"] : [])]);
|
|
88
92
|
const n = checkDate(c, `${p}.date`, entry["date"]);
|
|
@@ -116,7 +120,7 @@ export function compileAnnualRules(c, path, entries, valueOf, allowString, value
|
|
|
116
120
|
return [];
|
|
117
121
|
}
|
|
118
122
|
const rules = [];
|
|
119
|
-
entries.forEach((raw, i) => {
|
|
123
|
+
Array.from(entries).forEach((raw, i) => {
|
|
120
124
|
const p = `${path}[${i}]`;
|
|
121
125
|
const entry = allowString && typeof raw === "string" ? { date: raw } : raw;
|
|
122
126
|
if (!isObject(entry)) {
|
|
@@ -127,6 +131,10 @@ export function compileAnnualRules(c, path, entries, valueOf, allowString, value
|
|
|
127
131
|
const name = checkName(c, p, entry["name"]);
|
|
128
132
|
const period = checkPeriod(c, p, entry);
|
|
129
133
|
const defined = withoutUndefined(entry, DATE_SHAPE_KEYS);
|
|
134
|
+
if ("date" in defined && ("from" in defined || "to" in defined)) {
|
|
135
|
+
c.error("invalid-option", p, 'cannot have both "date" and "from"/"to"');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
130
138
|
if ("date" in defined) {
|
|
131
139
|
checkUnknownKeys(c, p, defined, [
|
|
132
140
|
"date",
|
|
@@ -191,7 +199,7 @@ const isDayOfMonth = (v) => v === -1 || (Number.isInteger(v) && v >= 1 && v <= 3
|
|
|
191
199
|
const isMonth = (v) => Number.isInteger(v) && v >= 1 && v <= 12;
|
|
192
200
|
function checkSet(c, path, raw, valid, expected, elementCode = "invalid-option") {
|
|
193
201
|
const list = Array.isArray(raw) ? raw : [raw];
|
|
194
|
-
if (list.length === 0 || !list.every(valid)) {
|
|
202
|
+
if (list.length === 0 || !Array.from(list).every(valid)) {
|
|
195
203
|
c.error(list.length === 0 ? "invalid-option" : elementCode, path, `must be ${expected}, or a non-empty array of them`);
|
|
196
204
|
return undefined;
|
|
197
205
|
}
|
|
@@ -205,7 +213,7 @@ export function compileRecurringRules(c, path, entries, valueOf, keys, context,
|
|
|
205
213
|
return [];
|
|
206
214
|
}
|
|
207
215
|
const rules = [];
|
|
208
|
-
entries.forEach((rawEntry, i) => {
|
|
216
|
+
Array.from(entries).forEach((rawEntry, i) => {
|
|
209
217
|
const p = `${path}[${i}]`;
|
|
210
218
|
if (!isObject(rawEntry)) {
|
|
211
219
|
c.error("invalid-option", p, "must be an object");
|
|
@@ -333,7 +341,7 @@ export function compileRecurringRules(c, path, entries, valueOf, keys, context,
|
|
|
333
341
|
}
|
|
334
342
|
else if (cycle !== null) {
|
|
335
343
|
const n = cycle;
|
|
336
|
-
if (!raw.every((v) => Number.isInteger(v) && v >= 1 && v <= n)) {
|
|
344
|
+
if (!Array.from(raw).every((v) => Number.isInteger(v) && v >= 1 && v <= n)) {
|
|
337
345
|
c.error("invalid-option", `${p}.positions`, `must be integers from 1 to ${n} (the cycle)`);
|
|
338
346
|
ok = false;
|
|
339
347
|
}
|
|
@@ -494,7 +502,11 @@ export function compileRecurringRules(c, path, entries, valueOf, keys, context,
|
|
|
494
502
|
ok = false;
|
|
495
503
|
}
|
|
496
504
|
}
|
|
497
|
-
const onHoliday = entry["holidayOverlapPolicy"]
|
|
505
|
+
const onHoliday = entry["holidayOverlapPolicy"] === undefined
|
|
506
|
+
? hasHoliday
|
|
507
|
+
? "over-holiday"
|
|
508
|
+
: "under-holiday"
|
|
509
|
+
: entry["holidayOverlapPolicy"];
|
|
498
510
|
if (!ON_HOLIDAY_RULES.includes(onHoliday)) {
|
|
499
511
|
c.error("invalid-option", `${p}.holidayOverlapPolicy`, `must be one of ${ON_HOLIDAY_RULES.map((v) => `"${v}"`).join(", ")}`);
|
|
500
512
|
ok = false;
|
|
@@ -712,7 +724,7 @@ export function compileHolidaySource(c, options) {
|
|
|
712
724
|
const list = raw === undefined ? [] : Array.isArray(raw) ? raw : [raw];
|
|
713
725
|
const providers = [];
|
|
714
726
|
const providerIndexes = [];
|
|
715
|
-
list.forEach((p, i) => {
|
|
727
|
+
Array.from(list).forEach((p, i) => {
|
|
716
728
|
const path = Array.isArray(raw) ? `holidayProvider[${i}]` : "holidayProvider";
|
|
717
729
|
if (validateProvider(c, path, p) && !providers.includes(p)) {
|
|
718
730
|
providers.push(p);
|
|
@@ -735,11 +747,13 @@ export function compileHolidaySource(c, options) {
|
|
|
735
747
|
}
|
|
736
748
|
timeZone = zones[0] ?? "UTC";
|
|
737
749
|
}
|
|
738
|
-
const outOfRangePolicy = options["outOfRangePolicy"]
|
|
750
|
+
const outOfRangePolicy = options["outOfRangePolicy"] === undefined ? "throw" : options["outOfRangePolicy"];
|
|
739
751
|
if (outOfRangePolicy !== "throw" && outOfRangePolicy !== "ignore") {
|
|
740
752
|
c.error("invalid-option", "outOfRangePolicy", 'must be "throw" or "ignore"');
|
|
741
753
|
}
|
|
742
|
-
const unconfirmed = options["unconfirmedHolidayPolicy"]
|
|
754
|
+
const unconfirmed = options["unconfirmedHolidayPolicy"] === undefined
|
|
755
|
+
? "accept"
|
|
756
|
+
: options["unconfirmedHolidayPolicy"];
|
|
743
757
|
if (unconfirmed !== "accept" && unconfirmed !== "throw") {
|
|
744
758
|
c.error("invalid-option", "unconfirmedHolidayPolicy", 'must be "accept" or "throw"');
|
|
745
759
|
}
|
|
@@ -947,6 +961,8 @@ export function compileScheduleOptions(c, options) {
|
|
|
947
961
|
}
|
|
948
962
|
let holiday = "ignore";
|
|
949
963
|
const holidayRaw = renameValue(c, "schedule", "holidayPolicy", writtenKey(["source", "schedule"], written, "holidayPolicy"), o["holidayPolicy"]);
|
|
964
|
+
if (isObject(holidayRaw))
|
|
965
|
+
checkUnknownKeys(c, "holidayPolicy", holidayRaw, ["sameAs", "value"]);
|
|
950
966
|
const hasSameAs = isObject(holidayRaw) && holidayRaw["sameAs"] !== undefined;
|
|
951
967
|
const hasValue = isObject(holidayRaw) && "value" in holidayRaw;
|
|
952
968
|
if (holidayRaw === undefined || holidayRaw === "ignore") {
|
package/dist/core/types.d.ts
CHANGED
|
@@ -38,8 +38,9 @@ export interface Holiday<Kind extends string = string> {
|
|
|
38
38
|
* holidaysInYear が返すデータは、年ごとに初めて使うときに検証され、誤りがあれば
|
|
39
39
|
* code: "invalid-provider-data" の例外になる。返した祝日は、契約の項目(date・name・nameEn・names・
|
|
40
40
|
* kind・confirmed・key)だけを持つ変更できないオブジェクトに複製される。
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* 祝日が長く続くとき、"after-holiday" の規則は、本来の日が振り替わる先の日より 31 日を超えて前にあると振り替わらない
|
|
42
|
+
* (振替元をさかのぼるのは 31 日まで。祝日の前後の規則は連続の長さによらず当てはまる。長い休業は closedDates・
|
|
43
|
+
* closedAnnualDates で書く。decisions.md の 24 番)。
|
|
43
44
|
*
|
|
44
45
|
* 項目を足すときのバージョンは RELEASING.md の区分の表による。1.0.0 以降、マイナーバージョンで足す項目は省略可能なものに限る
|
|
45
46
|
* (必須にすると、自作の提供元が型エラーになるため)。
|
package/dist/fr/rules.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - 固定日の祝日(1/1・5/1・5/8・7/14・8/15・11/1・11/11・12/25。Alsace-Moselle は 12/26 も)と、
|
|
5
5
|
* 復活祭から決まる祝日(Lundi de Pâques = +1 日、Ascension = +39 日、Lundi de Pentecôte = +50 日。
|
|
6
6
|
* Alsace-Moselle は Vendredi saint = −2 日も)を規則で計算する。振替はない
|
|
7
|
-
* - 2 つの祝日が同じ日に当たる年(復活祭が 3 月 23 日なら 5 月 1 日 = Ascension
|
|
7
|
+
* - 2 つの祝日が同じ日に当たる年(復活祭が 3 月 23 日なら 5 月 1 日 = Ascension、3 月 30 日なら 5 月 8 日 = Ascension)は、
|
|
8
8
|
* 復活祭から決まる祝日の名称・識別子で 1 件にする
|
|
9
9
|
* (data.gouv.fr の JSON と同じ扱い。提供元は 1 日に 1 件を返す契約のため)
|
|
10
10
|
* - 名称は data.gouv.fr の表記(フランス語)。nameEn はライブラリの英訳
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bizdays-toolkit",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.8",
|
|
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",
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
"holiday",
|
|
13
13
|
"holidays",
|
|
14
14
|
"japan",
|
|
15
|
+
"public-holidays",
|
|
15
16
|
"singapore",
|
|
17
|
+
"timezone",
|
|
18
|
+
"typescript",
|
|
16
19
|
"uk",
|
|
17
20
|
"workday",
|
|
18
21
|
"営業日",
|
|
@@ -89,8 +92,8 @@
|
|
|
89
92
|
},
|
|
90
93
|
"devDependencies": {
|
|
91
94
|
"@types/node": "26.6.6",
|
|
92
|
-
"oxfmt": "0.
|
|
93
|
-
"oxlint": "1.
|
|
95
|
+
"oxfmt": "0.78.0",
|
|
96
|
+
"oxlint": "1.93.0",
|
|
94
97
|
"typescript": "6.0.3"
|
|
95
98
|
},
|
|
96
99
|
"engines": {
|