bizdays-toolkit 0.31.0 → 0.31.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 +87 -55
- package/README.md +1 -1
- package/dist/core/calendar.d.ts +3 -13
- package/dist/core/calendar.js +23 -20
- package/dist/core/date.js +6 -6
- package/dist/core/diagnose.d.ts +4 -59
- package/dist/core/diagnose.js +27 -11
- package/dist/core/errors.d.ts +5 -61
- package/dist/core/errors.js +17 -0
- package/dist/core/input.d.ts +5 -21
- package/dist/core/input.js +17 -16
- package/dist/core/migrate.js +4 -7
- package/dist/core/month.d.ts +0 -19
- package/dist/core/month.js +4 -4
- package/dist/core/options.d.ts +5 -0
- package/dist/core/options.js +4 -0
- package/dist/core/renamed.d.ts +1 -39
- package/dist/core/schedule.d.ts +2 -203
- package/dist/core/schedule.js +21 -15
- package/dist/core/types.d.ts +4 -5
- package/dist/fr/rules.d.ts +1 -13
- package/dist/fr/rules.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/jp/rules.d.ts +1 -17
- package/dist/jp/rules.js +4 -2
- package/dist/provider/index.js +8 -7
- package/dist/sg/rules.d.ts +1 -13
- package/dist/sg/rules.js +3 -1
- package/dist/uk/rules.d.ts +1 -15
- package/dist/uk/rules.js +4 -2
- package/package.json +1 -1
package/dist/core/calendar.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addDays, lengthOfMonth, formatDate, fromDayNumber, toDayNumber, } from "./date.js";
|
|
2
|
-
import { checkUnknownKeys, internalError, IssueCollector, rangeError, withoutUndefined, } from "./errors.js";
|
|
2
|
+
import { checkUnknownKeys, internalError, IssueCollector, describeValue, rangeError, withoutUndefined, } from "./errors.js";
|
|
3
|
+
import { isOptionsObject } from "./options.js";
|
|
3
4
|
import { renameKeys, writtenKey } from "./renamed.js";
|
|
4
5
|
import { parseTimeOfDaySeconds, toCivil } from "./input.js";
|
|
5
6
|
import { checkClosingDay, closingDayIn, closingMonth as calendarClosingMonth, dayOfMonth, formatMonth, isDayOfMonthValue, parseMonth, shiftMonth, } from "./month.js";
|
|
@@ -19,7 +20,7 @@ export const CALENDAR_OPTION_KEYS = [
|
|
|
19
20
|
"searchDayLimit",
|
|
20
21
|
];
|
|
21
22
|
export function compileCalendarOptions(c, options) {
|
|
22
|
-
if (
|
|
23
|
+
if (!isOptionsObject(options)) {
|
|
23
24
|
c.error("invalid-option", "", "options must be an object");
|
|
24
25
|
return undefined;
|
|
25
26
|
}
|
|
@@ -211,7 +212,7 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
211
212
|
}
|
|
212
213
|
function nthOfMonth(month, n) {
|
|
213
214
|
if (!Number.isInteger(n) || n === 0) {
|
|
214
|
-
throw rangeError("invalid-argument", `n must be a non-zero integer: ${n}`);
|
|
215
|
+
throw rangeError("invalid-argument", `n must be a non-zero integer: ${describeValue(n)}`);
|
|
215
216
|
}
|
|
216
217
|
const days = businessDaysOfMonth(month);
|
|
217
218
|
const found = n > 0 ? days[n - 1] : days[days.length + n];
|
|
@@ -244,11 +245,12 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
244
245
|
previousBusinessDay: (input) => search(addDays(dateOf(input), -1), -1),
|
|
245
246
|
nextClosedDay: (input) => search(addDays(dateOf(input), 1), 1, false),
|
|
246
247
|
previousClosedDay: (input) => search(addDays(dateOf(input), -1), -1, false),
|
|
247
|
-
businessDayOnOrAfter(input,
|
|
248
|
+
businessDayOnOrAfter(input, options) {
|
|
249
|
+
const opts = optionsObject(options, "businessDayOnOrAfter options");
|
|
248
250
|
const civil = toCivil(input, lookup.timeZone);
|
|
249
251
|
let start = civil.date;
|
|
250
|
-
if (opts
|
|
251
|
-
const cutoff = parseTimeOfDaySeconds(opts
|
|
252
|
+
if (opts["cutoff"] !== undefined) {
|
|
253
|
+
const cutoff = parseTimeOfDaySeconds(opts["cutoff"]);
|
|
252
254
|
if (civil.minutes === null) {
|
|
253
255
|
throw rangeError("invalid-argument", "cutoff requires an input with a time of day (a Date, a date-time string or a Temporal value with a time); a date-only input would silently ignore the cutoff");
|
|
254
256
|
}
|
|
@@ -260,7 +262,7 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
260
262
|
businessDayOnOrBefore: (input) => search(dateOf(input), -1),
|
|
261
263
|
addBusinessDays(input, n) {
|
|
262
264
|
if (!Number.isInteger(n))
|
|
263
|
-
throw rangeError("invalid-argument", `n must be an integer: ${n}`);
|
|
265
|
+
throw rangeError("invalid-argument", `n must be an integer: ${describeValue(n)}`);
|
|
264
266
|
let date = dateOf(input);
|
|
265
267
|
if (n === 0)
|
|
266
268
|
return search(date, 1);
|
|
@@ -273,7 +275,7 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
273
275
|
diffBusinessDays(from, to) {
|
|
274
276
|
const a = toDayNumber(dateOf(from));
|
|
275
277
|
const b = toDayNumber(dateOf(to));
|
|
276
|
-
return a <= b ? countOpen(a, b) : -countOpen(b, a);
|
|
278
|
+
return a <= b ? countOpen(a, b) : 0 - countOpen(b, a);
|
|
277
279
|
},
|
|
278
280
|
businessDatesBetween(from, to) {
|
|
279
281
|
const a = dateOf(from);
|
|
@@ -307,10 +309,8 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
307
309
|
return Object.freeze({ from, to });
|
|
308
310
|
},
|
|
309
311
|
dueDate(month, options) {
|
|
310
|
-
const o =
|
|
311
|
-
|
|
312
|
-
: undefined;
|
|
313
|
-
const day = o?.["dayOfMonth"];
|
|
312
|
+
const o = optionsObject(options, "dueDate options", (v) => renameKeys("throw", ["dueDate"], "", v), true);
|
|
313
|
+
const day = o["dayOfMonth"];
|
|
314
314
|
if (!isDayOfMonthValue(day)) {
|
|
315
315
|
throw rangeError("invalid-argument", `dayOfMonth must be an integer from 1 to 31, or -1 (last day): ${String(day)}`);
|
|
316
316
|
}
|
|
@@ -321,7 +321,14 @@ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
|
|
|
321
321
|
};
|
|
322
322
|
return Object.freeze(calendar);
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
function optionsObject(options, what, rename = (v) => v, required = false, code = "invalid-argument") {
|
|
325
|
+
if (options === undefined && !required)
|
|
326
|
+
return {};
|
|
327
|
+
if (!isOptionsObject(options)) {
|
|
328
|
+
throw rangeError(code, `${what} must be an object: ${describeValue(options)}`);
|
|
329
|
+
}
|
|
330
|
+
return withoutUndefined(rename(options));
|
|
331
|
+
}
|
|
325
332
|
const isCalendarLike = (v) => typeof v === "object" &&
|
|
326
333
|
v !== null &&
|
|
327
334
|
typeof v.dayInfoOn === "function" &&
|
|
@@ -339,9 +346,7 @@ export function combineCalendars(calendars, options) {
|
|
|
339
346
|
throw rangeError("invalid-argument", `calendars[${i}] is the same calendar as calendars[${calendars.indexOf(c)}]`);
|
|
340
347
|
}
|
|
341
348
|
});
|
|
342
|
-
const o =
|
|
343
|
-
? withoutUndefined(renameKeys("throw", ["combine"], "", options))
|
|
344
|
-
: {};
|
|
349
|
+
const o = optionsObject(options, "combineCalendars options", (v) => renameKeys("throw", ["combine"], "", v), true, "invalid-option");
|
|
345
350
|
const mode = o["open"];
|
|
346
351
|
if (mode !== "all" && mode !== "any") {
|
|
347
352
|
throw rangeError("invalid-option", 'open must be "all" or "any"');
|
|
@@ -399,16 +404,14 @@ export function combineCalendars(calendars, options) {
|
|
|
399
404
|
return buildCalendar(lookup, isOpen, info, searchDayLimit);
|
|
400
405
|
}
|
|
401
406
|
export function createCalendarFromSchedule(schedule, isOpen, options) {
|
|
402
|
-
const info = infoOfSchedule(schedule);
|
|
407
|
+
const info = typeof schedule === "object" && schedule !== null ? infoOfSchedule(schedule) : undefined;
|
|
403
408
|
if (info === undefined) {
|
|
404
409
|
throw rangeError("invalid-argument", "schedule must be a schedule created by createSchedule");
|
|
405
410
|
}
|
|
406
411
|
if (typeof isOpen !== "function") {
|
|
407
412
|
throw rangeError("invalid-argument", "isOpen must be a function (value) => boolean");
|
|
408
413
|
}
|
|
409
|
-
const o =
|
|
410
|
-
? withoutUndefined(renameKeys("throw", ["fromSchedule"], "", options))
|
|
411
|
-
: {};
|
|
414
|
+
const o = optionsObject(options, "createCalendarFromSchedule options", (v) => renameKeys("throw", ["fromSchedule"], "", v), false, "invalid-option");
|
|
412
415
|
const searchDayLimit = (o["searchDayLimit"] ?? 3660);
|
|
413
416
|
if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
|
|
414
417
|
throw rangeError("invalid-option", "searchDayLimit must be a positive integer");
|
package/dist/core/date.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { rangeError } from "./errors.js";
|
|
1
|
+
import { describeValue, rangeError } from "./errors.js";
|
|
2
2
|
const DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
3
3
|
const MS_PER_DAY = 86_400_000;
|
|
4
4
|
const MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
5
5
|
export function parseDate(value) {
|
|
6
|
-
const m = DATE_RE.exec(value);
|
|
6
|
+
const m = typeof value === "string" ? DATE_RE.exec(value) : null;
|
|
7
7
|
if (!m) {
|
|
8
|
-
throw rangeError("invalid-date", `Invalid date string: ${
|
|
8
|
+
throw rangeError("invalid-date", `Invalid date string: ${describeValue(value)} (expected YYYY-MM-DD)`);
|
|
9
9
|
}
|
|
10
10
|
const year = Number(m[1]);
|
|
11
11
|
const month = Number(m[2]);
|
|
12
12
|
const day = Number(m[3]);
|
|
13
13
|
if (year < 1000 || month < 1 || month > 12 || day < 1 || day > lengthOfMonth(year, month)) {
|
|
14
|
-
throw rangeError("invalid-date", `Invalid date: ${value}`);
|
|
14
|
+
throw rangeError("invalid-date", `Invalid date: ${describeValue(value)}`);
|
|
15
15
|
}
|
|
16
16
|
return { year, month, day };
|
|
17
17
|
}
|
|
@@ -42,7 +42,7 @@ export function lengthOfMonth(year, month) {
|
|
|
42
42
|
return isLeapYear(year) ? 29 : 28;
|
|
43
43
|
const days = MONTH_DAYS[month - 1];
|
|
44
44
|
if (days === undefined)
|
|
45
|
-
throw rangeError("invalid-date", `Invalid month: ${month}`);
|
|
45
|
+
throw rangeError("invalid-date", `Invalid month: ${describeValue(month)}`);
|
|
46
46
|
return days;
|
|
47
47
|
}
|
|
48
48
|
export function toDayNumber(date) {
|
|
@@ -55,7 +55,7 @@ export function fromDayNumber(dayNumber) {
|
|
|
55
55
|
}
|
|
56
56
|
export function addDays(date, n) {
|
|
57
57
|
if (!Number.isInteger(n)) {
|
|
58
|
-
throw rangeError("invalid-argument", `n must be an integer: ${n}`);
|
|
58
|
+
throw rangeError("invalid-argument", `n must be an integer: ${describeValue(n)}`);
|
|
59
59
|
}
|
|
60
60
|
return fromDayNumber(toDayNumber(date) + n);
|
|
61
61
|
}
|
package/dist/core/diagnose.d.ts
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { type DateString } from "./date.ts";
|
|
31
31
|
import { type CalendarOptions } from "./calendar.ts";
|
|
32
|
-
import {
|
|
33
|
-
import { type
|
|
32
|
+
import { type KnownErrorCode } from "./errors.ts";
|
|
33
|
+
import { type ScheduleOptions } from "./schedule.ts";
|
|
34
34
|
/**
|
|
35
35
|
* 診断の重さ。
|
|
36
36
|
* - "error": 作成すると例外になる誤り
|
|
@@ -48,7 +48,7 @@ export type DiagnosticSeverity = "error" | "warning" | "info";
|
|
|
48
48
|
export type KnownDiagnosticCode = KnownErrorCode
|
|
49
49
|
/** 知らないキー(作成時は無視される) */
|
|
50
50
|
| "unknown-option"
|
|
51
|
-
/** 0.30.0 で改名した旧名のキー・値(新しい名前と同じに扱う。1.0.0
|
|
51
|
+
/** 0.30.0 で改名した旧名のキー・値(新しい名前と同じに扱う。1.0.0 での扱いは移行ガイドの「1.0.0 で削除する予定の API」) */
|
|
52
52
|
| "deprecated-option"
|
|
53
53
|
/** 同じ種類の先の規則に完全に覆われ、決して使われない */
|
|
54
54
|
| "shadowed"
|
|
@@ -61,7 +61,7 @@ export type KnownDiagnosticCode = KnownErrorCode
|
|
|
61
61
|
/** 第 n 営業日の規則の数える基準に、同じ設定の曜日の規則が入らない(その曜日を営業日として数える) */
|
|
62
62
|
| "counting-basis";
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* 診断コード。将来のバージョンで値が増えることがあるので、分岐では「その他」も扱うこと。
|
|
65
65
|
* @public
|
|
66
66
|
*/
|
|
67
67
|
export type DiagnosticCode = KnownDiagnosticCode | (string & {});
|
|
@@ -78,60 +78,6 @@ export interface Diagnostic {
|
|
|
78
78
|
/** 関係する別の位置(shadowed では覆っている先の規則、out-of-range では祝日の提供元) */
|
|
79
79
|
readonly relatedPath?: string;
|
|
80
80
|
}
|
|
81
|
-
interface Range {
|
|
82
|
-
readonly from: number;
|
|
83
|
-
readonly to: number;
|
|
84
|
-
}
|
|
85
|
-
interface Window {
|
|
86
|
-
readonly ranges: readonly Range[];
|
|
87
|
-
readonly label: string;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* 規則どうしの診断(redundant など)が調べる期間。analyzeRules が使う。テストのオラクル(test/diagnose-oracle.test.ts)も、
|
|
91
|
-
* 診断と同じ期間で「取り除いても結果が変わらない」かを確かめるために、同じ関数を使う
|
|
92
|
-
* @internal
|
|
93
|
-
*/
|
|
94
|
-
export declare function rulesScanWindow(compiled: Pick<CompiledSchedule<unknown, string>, "source" | "annual" | "recurring">, cycle?: number): Window | undefined;
|
|
95
|
-
/** @internal 判定できない日(窓の日の通し番号)と、基準が投げる月(年 × 12 + 月 - 1。見張りに使う) */
|
|
96
|
-
export interface Unjudgeable {
|
|
97
|
-
readonly days: ReadonlySet<number>;
|
|
98
|
-
readonly months: ReadonlySet<number>;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* @internal 判定できない日の集合 U を、規則を評価せずに決める(docs/decisions.md の 31 番)。単位は「その日について、結果の
|
|
102
|
-
* 分からない規則があるか」。基準のカレンダーを持つ規則ごとに、
|
|
103
|
-
*
|
|
104
|
-
* - 月の規則: 有効期間 ∩ 窓のうち months に当てはまる月で、基準が投げる月の日(有効期間 ∩ 窓の中)
|
|
105
|
-
* - 週の規則: 有効期間 ∩ 窓に 1 日でも入る週(weekStart で区切る)のうち、months に当てはまる日を含む週で、その 7 日が
|
|
106
|
-
* 属する月のどれかで基準が投げる週の 7 日
|
|
107
|
-
*
|
|
108
|
-
* U はその和。規則の形を調べる代表の 28 年間は含めない(第 n 営業日の規則の形は setCovers で比べ、代表の 28 年間で基準を
|
|
109
|
-
* 評価しない)。基準は繰り返しの規則に依存しないので、規則の並びや取り除きの順に左右されない
|
|
110
|
-
*/
|
|
111
|
-
export declare function unjudgeableDays<Value, Kind extends string>(compiled: CompiledSchedule<Value, Kind>, window: {
|
|
112
|
-
readonly ranges: readonly {
|
|
113
|
-
readonly from: number;
|
|
114
|
-
readonly to: number;
|
|
115
|
-
}[];
|
|
116
|
-
} | undefined): Unjudgeable;
|
|
117
|
-
/**
|
|
118
|
-
* @internal 判定できない日の影響を受けうる診断(never-matches・redundant)か。診断の項目は、path の先頭が規則の位置と一致する
|
|
119
|
-
* もので引く(規則の中のオプションの位置も同じ規則に当たる)。
|
|
120
|
-
*
|
|
121
|
-
* - 基準のカレンダーを持たない繰り返しの規則の never-matches と、その規則の中のオプションの診断は、規則の形と設定だけで
|
|
122
|
-
* 決まり、基準のカレンダーを評価しないので分かる
|
|
123
|
-
* - それ以外は、その項目の有効期間(個別の日付はその期間。期間がなければ全期間)に判定できない日があれば分からない。
|
|
124
|
-
* redundant は、取り除いた設定と元の設定の結果を比べるので、ほかの規則の基準のカレンダーの評価にも依存する
|
|
125
|
-
* - 規則に当たらない path の診断は分からない
|
|
126
|
-
*/
|
|
127
|
-
export declare function unsureOf<Value, Kind extends string>(compiled: CompiledSchedule<Value, Kind>, unknown: Unjudgeable): (code: string, path: string) => boolean;
|
|
128
|
-
/**
|
|
129
|
-
* @internal 見張り: 判定できない日にかかわる never-matches・redundant が残っていないことと、診断の途中で基準が投げた月が、
|
|
130
|
-
* 前もって求めた基準の投げる月(unjudgeableDays の months)に含まれることを確かめる。分からない規則は走査の前に決めて出さないので(走査の後で消すと、
|
|
131
|
-
* ほかの規則が「消した規則を外した設定」で判定されたままになる。31 番)、ここで見つかれば作りの誤り(黙って外れる検査を
|
|
132
|
-
* 作らない。RELEASING.md の「品質の仕組みの理由」の「規則を 1 か所に書く」)
|
|
133
|
-
*/
|
|
134
|
-
export declare function dropUnsure(c: IssueCollector, from: number, unsure: (code: string, path: string) => boolean, recorded: ReadonlySet<number>, unknown: Unjudgeable): void;
|
|
135
81
|
/** 診断を実行する。祝日の提供元の誤り(年ごとに初めて使うときに分かる)も error として返す */
|
|
136
82
|
/**
|
|
137
83
|
* 診断のオプション(第 2 引数)。
|
|
@@ -160,4 +106,3 @@ export declare function diagnoseCalendar(options?: CalendarOptions | object, dia
|
|
|
160
106
|
* @public
|
|
161
107
|
*/
|
|
162
108
|
export declare function diagnoseSchedule(options: ScheduleOptions<unknown> | object, diagnoseOptions?: DiagnoseOptions): readonly Diagnostic[];
|
|
163
|
-
export {};
|
package/dist/core/diagnose.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { lengthOfMonth, fromDayNumber, isValidDate, parseDate, toDayNumber, weekdayOf, } from "./date.js";
|
|
1
|
+
import { formatDate, lengthOfMonth, fromDayNumber, isValidDate, parseDate, toDayNumber, weekdayOf, } from "./date.js";
|
|
2
2
|
import { compileCalendarOptions } from "./calendar.js";
|
|
3
|
-
import { internalError, InternalError, IssueCollector, rangeError, } from "./errors.js";
|
|
3
|
+
import { internalError, InternalError, describeValue, IssueCollector, rangeError, } from "./errors.js";
|
|
4
|
+
import { isOptionsObject } from "./options.js";
|
|
4
5
|
import { RENAMED_KEYS, RENAMED_VALUES } from "./renamed.js";
|
|
5
|
-
import { compileScheduleOptions, createBasis, createHolidayLookup, createResolver, inPeriod, jpUsage, matchMonthDay, matchPattern, isHolidayBasedRule, resultIgnoresHolidays, } from "./schedule.js";
|
|
6
|
+
import { compileScheduleOptions, createBasis, createHolidayLookup, createResolver, inPeriod, MAX_HOLIDAY_RUN, jpUsage, matchMonthDay, matchPattern, isHolidayBasedRule, resultIgnoresHolidays, } from "./schedule.js";
|
|
6
7
|
function editDistance(a, b) {
|
|
7
8
|
const d = Array.from({ length: a.length + 1 }, (_, i) => Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)));
|
|
8
9
|
for (let i = 1; i <= a.length; i++) {
|
|
@@ -833,31 +834,46 @@ function analyzeRules(c, compiled, isCalendar, unsure = () => false) {
|
|
|
833
834
|
function compileDiagnoseOptions(options) {
|
|
834
835
|
if (options === undefined)
|
|
835
836
|
return { asOf: null };
|
|
836
|
-
if (
|
|
837
|
+
if (!isOptionsObject(options)) {
|
|
837
838
|
throw rangeError("invalid-argument", "the second argument must be an object of diagnose options");
|
|
838
839
|
}
|
|
839
840
|
const asOf = options.asOf;
|
|
840
841
|
if (asOf === undefined)
|
|
841
842
|
return { asOf: null };
|
|
842
843
|
if (!isValidDate(asOf)) {
|
|
843
|
-
throw rangeError("invalid-date", `asOf must be a date string "YYYY-MM-DD": ${
|
|
844
|
+
throw rangeError("invalid-date", `asOf must be a date string "YYYY-MM-DD": ${describeValue(asOf)}`);
|
|
844
845
|
}
|
|
845
846
|
return { asOf: toDayNumber(asOf) };
|
|
846
847
|
}
|
|
847
848
|
function checkExpired(c, compiled, asOf) {
|
|
848
|
-
const ended = (path, last, what) => {
|
|
849
|
-
if (
|
|
850
|
-
|
|
849
|
+
const ended = (path, last, what, reach = last, why = "") => {
|
|
850
|
+
if (reach < asOf) {
|
|
851
|
+
const until = reach > last ? ` (it could affect results until ${fromDayNumber(reach)}: ${why})` : "";
|
|
852
|
+
c.info("expired", path, `This ${what} ended on ${fromDayNumber(last)}${until}, before ${fromDayNumber(asOf)}; it no longer affects results and can be removed if the past need not be reproduced`);
|
|
851
853
|
}
|
|
852
854
|
};
|
|
855
|
+
const counting = compiled.recurring.filter((r) => r.businessDays !== null && r.basis === null);
|
|
856
|
+
const byMonth = counting.some((r) => r.weekStart === null);
|
|
857
|
+
const byWeek = counting.some((r) => r.weekStart !== null);
|
|
858
|
+
const countedReach = (last) => {
|
|
859
|
+
let reach = last;
|
|
860
|
+
if (byMonth) {
|
|
861
|
+
const { year, month } = parseDate(fromDayNumber(last));
|
|
862
|
+
reach = toDayNumber(formatDate(year, month, lengthOfMonth(year, month)));
|
|
863
|
+
}
|
|
864
|
+
return byWeek ? Math.max(reach, last + 6) : reach;
|
|
865
|
+
};
|
|
866
|
+
const COUNTED = "a rule counting the business days of a month or week counts it";
|
|
853
867
|
for (const r of compiled.dates)
|
|
854
|
-
ended(r.path, r.to, "date");
|
|
868
|
+
ended(r.path, r.to, "date", countedReach(r.to), COUNTED);
|
|
855
869
|
for (const r of compiled.annual)
|
|
856
870
|
if (r.effectiveTo !== null)
|
|
857
|
-
ended(r.path, r.effectiveTo, "rule");
|
|
871
|
+
ended(r.path, r.effectiveTo, "rule", countedReach(r.effectiveTo), COUNTED);
|
|
858
872
|
for (const r of compiled.recurring)
|
|
859
873
|
if (r.effectiveTo !== null)
|
|
860
|
-
ended(r.path, r.effectiveTo, "rule"
|
|
874
|
+
ended(r.path, r.effectiveTo, "rule", r.holidayOverlapPolicy === "after-holiday"
|
|
875
|
+
? r.effectiveTo + MAX_HOLIDAY_RUN
|
|
876
|
+
: r.effectiveTo, `a day moved by "after-holiday" falls at most ${MAX_HOLIDAY_RUN} days after it`);
|
|
861
877
|
}
|
|
862
878
|
function checkUnconfirmedOption(c, compiled) {
|
|
863
879
|
if (compiled.source.unconfirmedHolidayPolicy !== "throw")
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* コード付きの例外と、入力の問題を集める仕組み。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* ほかのすべての code(値の誤りも、引数の型の誤りも)は RangeError。同じ code はどの経路でも同じクラスで投げる。
|
|
4
|
+
* 例外のクラスと code の対応、メッセージの扱いは decisions.md の 3 番、どの誤りがどの code になるかは 8 番。
|
|
6
5
|
* 到達しない箇所の例外(作りの誤り)だけは code を持たない InternalError(internalError で作る)。
|
|
7
|
-
* 例外のメッセージの文言は API に含まない(変わることがある)。判定には code を使う。
|
|
8
6
|
* 問題を集める仕組み(IssueCollector)は、作成時のチェックと規則の診断(diagnose)で共通。
|
|
9
7
|
*/
|
|
10
8
|
/**
|
|
@@ -28,13 +26,13 @@ export type KnownErrorCode =
|
|
|
28
26
|
| "invalid-range"
|
|
29
27
|
/** 曜日の番号(0〜6)の誤り */
|
|
30
28
|
| "invalid-weekday"
|
|
31
|
-
/**
|
|
29
|
+
/** 設定以外の引数の誤り(メソッドのオプションの誤り、整数でない日数など) */
|
|
32
30
|
| "invalid-argument"
|
|
33
|
-
/**
|
|
31
|
+
/** 設定の誤り。設定は営業日カレンダー・スケジュールを作る関数が検証するオブジェクトで、オブジェクトでないことも含む(decisions.md の 8 番) */
|
|
34
32
|
| "invalid-option"
|
|
35
33
|
/** 祝日の提供元どうしのタイムゾーンが異なり、timeZone の指定が必要 */
|
|
36
34
|
| "time-zone-conflict"
|
|
37
|
-
/**
|
|
35
|
+
/** 対応している年の範囲の外(提供元の対応年、または日付の計算が 1000〜9999 年の外に出た)。bizdays-toolkit/provider の関数の年の引数の誤りは invalid-argument */
|
|
38
36
|
| "out-of-range"
|
|
39
37
|
/** 判定が未確定の祝日(confirmed: false)に触れた(unconfirmedHolidayPolicy: "throw") */
|
|
40
38
|
| "unconfirmed-holiday"
|
|
@@ -47,7 +45,7 @@ export type KnownErrorCode =
|
|
|
47
45
|
/** searchDayLimit の日数のうちに休業日が見つからない(nextClosedDay・previousClosedDay) */
|
|
48
46
|
| "no-closed-day";
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
48
|
+
* エラーコード。将来のバージョンで値が増えることがある。
|
|
51
49
|
* @public
|
|
52
50
|
*/
|
|
53
51
|
export type ErrorCode = KnownErrorCode | (string & {});
|
|
@@ -58,57 +56,3 @@ export type ErrorCode = KnownErrorCode | (string & {});
|
|
|
58
56
|
export declare function isBizdaysError(error: unknown): error is Error & {
|
|
59
57
|
readonly code: ErrorCode;
|
|
60
58
|
};
|
|
61
|
-
/** @internal */
|
|
62
|
-
export declare function rangeError(code: KnownErrorCode, message: string): RangeError;
|
|
63
|
-
/**
|
|
64
|
-
* @internal 作りの誤り(到達しないはずの箇所・保証が破れたとき)の例外。code を持たず(isBizdaysError は false)、
|
|
65
|
-
* 診断は提供元の誤りとして報告せずにそのまま投げる。設定や入力の誤りには使わない
|
|
66
|
-
*/
|
|
67
|
-
export declare class InternalError extends Error {
|
|
68
|
-
readonly name = "InternalError";
|
|
69
|
-
}
|
|
70
|
-
/** @internal 作りの誤りの例外を作る(到達しない箇所の例外は、すべてこの形にする) */
|
|
71
|
-
export declare function internalError(message: string): InternalError;
|
|
72
|
-
/** @internal */
|
|
73
|
-
export declare function typeError(code: KnownErrorCode, message: string): TypeError;
|
|
74
|
-
/** @internal 問題の重さ */
|
|
75
|
-
export type IssueSeverity = "error" | "warning" | "info";
|
|
76
|
-
/** @internal 設定の問題 1 件 */
|
|
77
|
-
export interface Issue {
|
|
78
|
-
readonly severity: IssueSeverity;
|
|
79
|
-
readonly code: string;
|
|
80
|
-
/** 設定の中の位置(例: "dates[1].from")。設定全体なら "" */
|
|
81
|
-
readonly path: string;
|
|
82
|
-
readonly message: string;
|
|
83
|
-
/** 関係する別の位置(例: 覆っている先の規則) */
|
|
84
|
-
readonly relatedPath?: string;
|
|
85
|
-
/** unknown-option の知らないキーと既知のキー(診断で候補を挙げるため。結果には出さない) */
|
|
86
|
-
readonly unknownKey?: string;
|
|
87
|
-
readonly knownKeys?: readonly string[];
|
|
88
|
-
/** 和集合の設定の kinds の "national"(診断で、当てている祝日と 1.0.0 での扱いを添えるため。結果には出さない) */
|
|
89
|
-
readonly nationalInUnion?: true;
|
|
90
|
-
}
|
|
91
|
-
/** @internal 問題を集める */
|
|
92
|
-
export declare class IssueCollector {
|
|
93
|
-
readonly issues: Issue[];
|
|
94
|
-
error(code: KnownErrorCode, path: string, message: string): void;
|
|
95
|
-
warning(code: string, path: string, message: string, relatedPath?: string): void;
|
|
96
|
-
info(code: string, path: string, message: string, relatedPath?: string): void;
|
|
97
|
-
private add;
|
|
98
|
-
get hasErrors(): boolean;
|
|
99
|
-
/** 最初の誤りを例外にして投げる(誤りがなければ何もしない) */
|
|
100
|
-
throwFirstError(): void;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* @internal 値が undefined の項目を除いた複製(なければ元のオブジェクト)。設定の明示的な undefined は省略と同じ
|
|
104
|
-
* (decisions.md の 6 番)。知らないキーの検査(checkUnknownKeys)は除く前のオブジェクトに対して行う。
|
|
105
|
-
* スケジュールの value は undefined も値として持てるので除かない
|
|
106
|
-
*/
|
|
107
|
-
export declare function withoutUndefined(value: Record<string, unknown>,
|
|
108
|
-
/** 除く項目を限るとき、その項目 */
|
|
109
|
-
keys?: readonly string[]): Record<string, unknown>;
|
|
110
|
-
/**
|
|
111
|
-
* @internal 設定のオブジェクトに、知らないキーがあれば警告として記録する。
|
|
112
|
-
* 近い既知のキーを候補に挙げるのは規則の診断で行う(作成時は警告を使わないので、ここでは既知のキーを渡すだけ)
|
|
113
|
-
*/
|
|
114
|
-
export declare function checkUnknownKeys(collector: IssueCollector, path: string, value: object, known: readonly string[]): void;
|
package/dist/core/errors.js
CHANGED
|
@@ -17,6 +17,23 @@ export class InternalError extends Error {
|
|
|
17
17
|
export function internalError(message) {
|
|
18
18
|
return new InternalError(`bizdays-toolkit internal error: ${message}`);
|
|
19
19
|
}
|
|
20
|
+
export function describeValue(value) {
|
|
21
|
+
if (typeof value === "number" || typeof value === "symbol")
|
|
22
|
+
return String(value);
|
|
23
|
+
if (typeof value === "bigint")
|
|
24
|
+
return `${value}n`;
|
|
25
|
+
if (typeof value === "function")
|
|
26
|
+
return "a function";
|
|
27
|
+
const tag = Object.prototype.toString.call(value);
|
|
28
|
+
if (value && typeof value === "object" && !/^\[object (Object|Array)\]$/.test(tag))
|
|
29
|
+
return tag;
|
|
30
|
+
try {
|
|
31
|
+
return JSON.stringify(value) ?? String(value);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return tag;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
20
37
|
export function typeError(code, message) {
|
|
21
38
|
return withCode(new TypeError(message), code);
|
|
22
39
|
}
|
package/dist/core/input.d.ts
CHANGED
|
@@ -60,18 +60,11 @@ export interface CivilDateTimeParts<Time extends string | null = string | null>
|
|
|
60
60
|
/** 時刻 "HH:mm"。暦日だけの入力では null */
|
|
61
61
|
readonly time: Time;
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
/** @internal IANA タイムゾーン名として使えるか確かめ、正規化した名前を返す(不正なら RangeError) */
|
|
70
|
-
export declare function validateTimeZone(timeZone: string): string;
|
|
71
|
-
/** @internal 瞬間(エポックミリ秒)を、タイムゾーンでの暦日と時刻に変換する */
|
|
72
|
-
export declare function instantToCivil(epochMilliseconds: number, timeZone: string): CivilDateTime;
|
|
73
|
-
/** @internal 入力をタイムゾーンでの暦日と時刻に変換する */
|
|
74
|
-
export declare function toCivil(input: DateInput, timeZone: string): CivilDateTime;
|
|
63
|
+
/**
|
|
64
|
+
* Date か(iframe や vm など、別の実行環境で作られた Date も含む)。
|
|
65
|
+
* instanceof は実行環境ごとに Date が別物になるため使わない
|
|
66
|
+
*/
|
|
67
|
+
export declare function isDate(value: unknown): value is Date;
|
|
75
68
|
/**
|
|
76
69
|
* 入力を、タイムゾーンでの暦日 "YYYY-MM-DD" に変換する。
|
|
77
70
|
* @public
|
|
@@ -85,15 +78,6 @@ export declare function toDateString(input: DateInput, timeZone: string): DateSt
|
|
|
85
78
|
export declare function toDateTimeParts(input: DateTimeInput, timeZone: string): CivilDateTimeParts<string>;
|
|
86
79
|
/** @public */
|
|
87
80
|
export declare function toDateTimeParts(input: DateInput, timeZone: string): CivilDateTimeParts;
|
|
88
|
-
/**
|
|
89
|
-
* @internal 暦日と時刻(0 時からの経過分)から、タイムゾーンでの瞬間(エポックミリ秒)を求める。
|
|
90
|
-
* 夏時間の扱いは Temporal の disambiguation: "compatible" と同じ。存在しない時刻(飛び)は切り替え前のオフセットで解釈して
|
|
91
|
-
* 飛んだ分だけ後ろの瞬間に、2 回ある時刻(重複)は先のほう(切り替え前のオフセット)にする。
|
|
92
|
-
* Intl 以外に依存しないよう、前後 1 日のオフセットを候補にして、暦日に戻して一致するものを選ぶ
|
|
93
|
-
*/
|
|
94
|
-
export declare function civilToInstant(date: DateString, minutes: number, timeZone: string): number;
|
|
95
|
-
/** @internal "HH:mm" または "HH:mm:ss" を 0 時からの経過秒に変換する(00:00:00〜23:59:59) */
|
|
96
|
-
export declare function parseTimeOfDaySeconds(value: unknown): number;
|
|
97
81
|
/**
|
|
98
82
|
* 暦日と時刻("HH:mm" または "HH:mm:ss")から、タイムゾーンでのその瞬間を Date で返す(civilOf・toDateTimeParts の逆向き)。
|
|
99
83
|
* 夏時間の切り替えで存在しない時刻は、飛んだ分だけ後ろの瞬間(英国の 3 月の 01:30 は 02:30 BST)、2 回ある時刻は先のほう
|
package/dist/core/input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { formatDate, parseDate } from "./date.js";
|
|
2
|
-
import { rangeError, typeError } from "./errors.js";
|
|
3
|
-
const DATETIME_RE = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(
|
|
2
|
+
import { describeValue, rangeError, typeError } from "./errors.js";
|
|
3
|
+
const DATETIME_RE = /^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:?\d{2})?$/i;
|
|
4
4
|
const formatters = new Map();
|
|
5
5
|
function formatterFor(timeZone) {
|
|
6
6
|
let f = formatters.get(timeZone);
|
|
@@ -20,13 +20,13 @@ function formatterFor(timeZone) {
|
|
|
20
20
|
}
|
|
21
21
|
export function validateTimeZone(timeZone) {
|
|
22
22
|
if (typeof timeZone !== "string" || timeZone === "") {
|
|
23
|
-
throw rangeError("invalid-time-zone", `Invalid time zone: ${
|
|
23
|
+
throw rangeError("invalid-time-zone", `Invalid time zone: ${describeValue(timeZone)}`);
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
26
|
return formatterFor(timeZone).resolvedOptions().timeZone;
|
|
27
27
|
}
|
|
28
28
|
catch {
|
|
29
|
-
throw rangeError("invalid-time-zone", `Invalid time zone: ${
|
|
29
|
+
throw rangeError("invalid-time-zone", `Invalid time zone: ${describeValue(timeZone)}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
export function instantToCivil(epochMilliseconds, timeZone) {
|
|
@@ -51,7 +51,8 @@ function wallTime(hour, minute) {
|
|
|
51
51
|
!Number.isInteger(minute) ||
|
|
52
52
|
minute < 0 ||
|
|
53
53
|
minute > 59) {
|
|
54
|
-
|
|
54
|
+
const two = (v) => String(v).padStart(2, "0");
|
|
55
|
+
throw rangeError("invalid-time", `Invalid time: ${two(hour)}:${two(minute)}`);
|
|
55
56
|
}
|
|
56
57
|
return hour * 60 + minute;
|
|
57
58
|
}
|
|
@@ -62,22 +63,22 @@ function parseString(value, timeZone) {
|
|
|
62
63
|
}
|
|
63
64
|
const m = DATETIME_RE.exec(value);
|
|
64
65
|
if (!m) {
|
|
65
|
-
throw rangeError(/^\d{4}-\d{2}-\d{2}[T ]/i.test(value) ? "invalid-time" : "invalid-date", `Invalid date/time string: ${
|
|
66
|
+
throw rangeError(/^\d{4}-\d{2}-\d{2}[T ]/i.test(value) ? "invalid-time" : "invalid-date", `Invalid date/time string: ${describeValue(value)} (expected YYYY-MM-DD or ISO 8601 date-time)`);
|
|
66
67
|
}
|
|
67
68
|
const date = m[1];
|
|
68
|
-
parseDate(date);
|
|
69
|
+
const { year, month, day } = parseDate(date);
|
|
69
70
|
const minutes = wallTime(Number(m[2]), Number(m[3]));
|
|
70
71
|
if (m[4] !== undefined && Number(m[4]) > 59) {
|
|
71
|
-
throw rangeError("invalid-time", `Invalid time: ${value}`);
|
|
72
|
+
throw rangeError("invalid-time", `Invalid date/time string: ${describeValue(value)}`);
|
|
72
73
|
}
|
|
73
|
-
const offset = m[
|
|
74
|
+
const offset = m[6];
|
|
74
75
|
if (offset === undefined)
|
|
75
76
|
return { date, minutes };
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const [, hh = "0", mm = "0"] = /(\d\d):?(\d\d)$/.exec(offset) ?? [];
|
|
78
|
+
if (+hh > 23 || +mm > 59)
|
|
79
|
+
throw rangeError("invalid-time", `Invalid date/time string: ${describeValue(value)}`);
|
|
80
|
+
const ms = Date.UTC(year, month - 1, day, 0, minutes, +(m[4] ?? 0), +(m[5] ?? "0").padEnd(3, "0").slice(0, 3)) -
|
|
81
|
+
(offset[0] === "-" ? -1 : 1) * (+hh * 60 + +mm) * 60_000;
|
|
81
82
|
return instantToCivil(ms, timeZone);
|
|
82
83
|
}
|
|
83
84
|
function isInstantLike(value) {
|
|
@@ -87,7 +88,7 @@ function isDateLike(value) {
|
|
|
87
88
|
const v = value;
|
|
88
89
|
return typeof v.year === "number" && typeof v.month === "number" && typeof v.day === "number";
|
|
89
90
|
}
|
|
90
|
-
function isDate(value) {
|
|
91
|
+
export function isDate(value) {
|
|
91
92
|
return Object.prototype.toString.call(value) === "[object Date]";
|
|
92
93
|
}
|
|
93
94
|
export function toCivil(input, timeZone) {
|
|
@@ -144,7 +145,7 @@ export function parseTimeOfDaySeconds(value) {
|
|
|
144
145
|
const m = typeof value === "string" ? /^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(value) : null;
|
|
145
146
|
const seconds = m ? Number(m[3] ?? "0") : NaN;
|
|
146
147
|
if (!m || seconds > 59) {
|
|
147
|
-
throw rangeError("invalid-time", `Invalid time of day: ${
|
|
148
|
+
throw rangeError("invalid-time", `Invalid time of day: ${describeValue(value)} (expected HH:mm or HH:mm:ss)`);
|
|
148
149
|
}
|
|
149
150
|
return wallTime(Number(m[1]), Number(m[2])) * 60 + seconds;
|
|
150
151
|
}
|
package/dist/core/migrate.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { rangeError } from "./errors.js";
|
|
2
|
+
import { isOptionsObject } from "./options.js";
|
|
2
3
|
import { RENAMED_KEYS, RENAMED_VALUES } from "./renamed.js";
|
|
3
|
-
const isPlain = (v) => typeof v === "object" &&
|
|
4
|
-
v !== null &&
|
|
5
|
-
!Array.isArray(v) &&
|
|
6
|
-
(Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
|
|
7
4
|
const SHARED_KEYS = new Set(["holidayProvider", "holidays", "calendar", "value"]);
|
|
8
5
|
const VALUE_LISTS = new Set(["weekdayValues", "weekly"]);
|
|
9
6
|
function clone(v) {
|
|
10
7
|
if (Array.isArray(v))
|
|
11
8
|
return v.map(clone);
|
|
12
|
-
if (!
|
|
9
|
+
if (!isOptionsObject(v))
|
|
13
10
|
return v;
|
|
14
11
|
const out = {};
|
|
15
12
|
for (const [k, x] of Object.entries(v)) {
|
|
@@ -58,7 +55,7 @@ function renameValues(value, place, key, path, changes) {
|
|
|
58
55
|
return Array.isArray(value) ? value.map((v, i) => one(v, `${path}[${i}]`)) : one(value, path);
|
|
59
56
|
}
|
|
60
57
|
function migrate(input, places, ruleLists, policyValueKey) {
|
|
61
|
-
if (!
|
|
58
|
+
if (!isOptionsObject(input))
|
|
62
59
|
throw rangeError("invalid-argument", "options must be a plain object");
|
|
63
60
|
const changes = [];
|
|
64
61
|
const copied = clone(input);
|
|
@@ -75,7 +72,7 @@ function migrate(input, places, ruleLists, policyValueKey) {
|
|
|
75
72
|
continue;
|
|
76
73
|
const at = written.get(list) ?? list;
|
|
77
74
|
out[list] = rules.map((rule, i) => {
|
|
78
|
-
if (!
|
|
75
|
+
if (!isOptionsObject(rule))
|
|
79
76
|
return rule;
|
|
80
77
|
const renamed = renameObject(rule, ["rule"], `${at}[${i}]`, changes);
|
|
81
78
|
if (jp && renamed["kinds"] !== undefined)
|
package/dist/core/month.d.ts
CHANGED
|
@@ -10,21 +10,6 @@ import { type DateString } from "./date.ts";
|
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
12
|
export type MonthString = string;
|
|
13
|
-
/** @internal 年と月 */
|
|
14
|
-
export interface YearMonth {
|
|
15
|
-
readonly year: number;
|
|
16
|
-
readonly month: number;
|
|
17
|
-
}
|
|
18
|
-
/** @internal "YYYY-MM" を年と月に分解する(誤りは code: "invalid-month") */
|
|
19
|
-
export declare function parseMonth(value: unknown): YearMonth;
|
|
20
|
-
/** @internal 年と月を "YYYY-MM" にする(年が 1000〜9999 の外なら code: "out-of-range") */
|
|
21
|
-
export declare function formatMonth({ year, month }: YearMonth): MonthString;
|
|
22
|
-
/** @internal n か月後(負なら前)の年と月 */
|
|
23
|
-
export declare function shiftMonth({ year, month }: YearMonth, offset: number): YearMonth;
|
|
24
|
-
/** @internal その月の d 日(その月にない日・-1 は末日に読み替える) */
|
|
25
|
-
export declare function dayOfMonth({ year, month }: YearMonth, day: number): DateString;
|
|
26
|
-
/** @internal 月の日(1〜31、-1 は末日)として正しいか */
|
|
27
|
-
export declare const isDayOfMonthValue: (v: unknown) => v is number;
|
|
28
13
|
/**
|
|
29
14
|
* 日付または月の、offset か月後(負なら前)の月 "YYYY-MM"。
|
|
30
15
|
*
|
|
@@ -48,10 +33,6 @@ export declare function monthOf(input: DateString | MonthString, offset?: number
|
|
|
48
33
|
* @public
|
|
49
34
|
*/
|
|
50
35
|
export declare function closingMonth(date: DateString, closingDayOfMonth: number): MonthString;
|
|
51
|
-
/** @internal 締め日の検証(closingMonth・closingPeriod・営業日カレンダーの締め日で共用) */
|
|
52
|
-
export declare function checkClosingDay(closingDayOfMonth: number): void;
|
|
53
|
-
/** @internal その月の締め日(日)。-1 またはその月の日数以上なら末日(decisions.md の 23 番の読み替えはここだけで行う) */
|
|
54
|
-
export declare function closingDayIn({ year, month }: YearMonth, closingDayOfMonth: number): number;
|
|
55
36
|
/**
|
|
56
37
|
* 締め日で区切ったときの、その月分の期間(両端を含む暦日)。closingMonth の逆算。
|
|
57
38
|
*
|