bizdays-toolkit 0.22.2 → 0.30.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.
@@ -1,28 +1,31 @@
1
- import { addDays, daysInMonth, formatDate, fromDayNumber, toDayNumber, } from "./date.js";
1
+ import { addDays, lengthOfMonth, formatDate, fromDayNumber, toDayNumber, } from "./date.js";
2
2
  import { checkUnknownKeys, IssueCollector, plainError, rangeError } from "./errors.js";
3
+ import { renameKeys, writtenKey } from "./renamed.js";
3
4
  import { parseTimeOfDay, toCivil } from "./input.js";
4
5
  import { checkClosingDay, closingDayIn, closingMonth as calendarClosingMonth, dayOfMonth, formatMonth, isDayOfMonthValue, parseMonth, shiftMonth, } from "./month.js";
5
- import { buildSchedule, compileAnnualRules, compileDateRules, compileHolidaySource, compileRecurringRules, createHolidayLookup, infoOfSchedule, isWeekday, mapDays, RECURRING_RULE_KEYS, } from "./schedule.js";
6
+ import { buildSchedule, compileAnnualRules, compileDateRules, compileHolidaySource, compileRecurringRules, createHolidayLookup, infoOfSchedule, isWeekday, mapDays, RECURRING_RULE_KEYS, usesJp, } from "./schedule.js";
6
7
  const CALENDAR_OPTION_KEYS = [
7
- "holidays",
8
+ "holidayProvider",
8
9
  "timeZone",
9
- "outOfRange",
10
- "unconfirmedHolidays",
10
+ "outOfRangePolicy",
11
+ "unconfirmedHolidayPolicy",
11
12
  "closedWeekdays",
12
- "closedAnnual",
13
+ "closedAnnualDates",
13
14
  "closedDates",
14
15
  "openDates",
15
- "closedRecurring",
16
- "openRecurring",
16
+ "closedRecurringRules",
17
+ "openRecurringRules",
17
18
  "holidayPolicy",
18
- "maxSearchDays",
19
+ "searchDayLimit",
19
20
  ];
20
21
  export function compileCalendarOptions(c, options) {
21
22
  if (typeof options !== "object" || options === null || Array.isArray(options)) {
22
23
  c.error("invalid-option", "", "options must be an object");
23
24
  return undefined;
24
25
  }
25
- const o = options;
26
+ const written = options;
27
+ const places = ["source", "calendar"];
28
+ const o = renameKeys(c, places, "", written);
26
29
  checkUnknownKeys(c, "", o, CALENDAR_OPTION_KEYS);
27
30
  const source = compileHolidaySource(c, o);
28
31
  const closedWeekdays = new Set();
@@ -44,40 +47,40 @@ export function compileCalendarOptions(c, options) {
44
47
  if (holidayPolicy !== "closed" && holidayPolicy !== "open" && holidayPolicy !== "ignore") {
45
48
  c.error("invalid-option", "holidayPolicy", 'must be "closed", "open" or "ignore"');
46
49
  }
47
- const maxSearchDays = o["maxSearchDays"] ?? 3660;
48
- if (!Number.isInteger(maxSearchDays) || maxSearchDays < 1) {
49
- c.error("invalid-option", "maxSearchDays", "must be a positive integer");
50
+ const searchDayLimit = o["searchDayLimit"] ?? 3660;
51
+ if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
52
+ c.error("invalid-option", "searchDayLimit", "must be a positive integer");
50
53
  }
51
- const annual = compileAnnualRules(c, "closedAnnual", o["closedAnnual"], () => false, true);
54
+ const annual = compileAnnualRules(c, "closedAnnualDates", o["closedAnnualDates"], () => false, true);
52
55
  const open = compileDateRules(c, "openDates", o["openDates"], () => true, true);
53
56
  const closed = compileDateRules(c, "closedDates", o["closedDates"], () => false, true);
54
- const openRecurring = compileRecurringRules(c, "openRecurring", o["openRecurring"], () => true, RECURRING_RULE_KEYS, "calendar");
55
- const closedRecurring = compileRecurringRules(c, "closedRecurring", o["closedRecurring"], () => false, RECURRING_RULE_KEYS, "calendar");
57
+ const openRecurringRules = compileRecurringRules(c, "openRecurringRules", o["openRecurringRules"], () => true, RECURRING_RULE_KEYS, "calendar", writtenKey(places, written, "openRecurringRules"), usesJp(source));
58
+ const closedRecurringRules = compileRecurringRules(c, "closedRecurringRules", o["closedRecurringRules"], () => false, RECURRING_RULE_KEYS, "calendar", writtenKey(places, written, "closedRecurringRules"), usesJp(source));
56
59
  return {
57
60
  schedule: {
58
61
  source,
59
62
  weekly: Object.freeze([0, 1, 2, 3, 4, 5, 6].map((w) => !closedWeekdays.has(w))),
60
- holiday: holidayPolicy === "ignore" ? "weekday" : { value: holidayPolicy === "open" },
63
+ holiday: holidayPolicy === "ignore" ? "ignore" : { value: holidayPolicy === "open" },
61
64
  annual,
62
65
  dates: [...open, ...closed],
63
- recurring: [...openRecurring, ...closedRecurring],
66
+ recurring: [...openRecurringRules, ...closedRecurringRules],
64
67
  },
65
- maxSearchDays: Number.isInteger(maxSearchDays) ? maxSearchDays : 3660,
68
+ searchDayLimit: Number.isInteger(searchDayLimit) ? searchDayLimit : 3660,
66
69
  };
67
70
  }
68
71
  export function createCalendar(options = {}) {
69
72
  const c = new IssueCollector();
70
73
  const compiled = compileCalendarOptions(c, options);
71
74
  c.throwFirstError();
72
- const { maxSearchDays } = compiled;
75
+ const { searchDayLimit } = compiled;
73
76
  const schedule = buildSchedule(compiled.schedule);
74
77
  const info = (date) => {
75
- const day = schedule.dayInfo(date);
76
- return dayInfoFromScheduleDay(day, day.value);
78
+ const day = schedule.dayInfoOn(date);
79
+ return dayInfoFromScheduleDay(day, day.value, false);
77
80
  };
78
- return buildCalendar(schedule, (date) => schedule.valueOn(date), info, maxSearchDays);
81
+ return buildCalendar(schedule, (date) => schedule.valueOn(date), info, searchDayLimit);
79
82
  }
80
- function dayInfoFromScheduleDay(day, open) {
83
+ function dayInfoFromScheduleDay(day, open, fromSchedule) {
81
84
  let reason;
82
85
  const known = day.reason;
83
86
  switch (known) {
@@ -94,7 +97,7 @@ function dayInfoFromScheduleDay(day, open) {
94
97
  reason = "holiday";
95
98
  break;
96
99
  case "weekday":
97
- reason = open ? "regular" : "closed-weekday";
100
+ reason = open ? (fromSchedule ? "open-weekday" : "default") : "closed-weekday";
98
101
  break;
99
102
  default: {
100
103
  const unreachable = known;
@@ -104,6 +107,7 @@ function dayInfoFromScheduleDay(day, open) {
104
107
  const result = {
105
108
  date: day.date,
106
109
  weekday: day.weekday,
110
+ open,
107
111
  businessDay: open,
108
112
  reason,
109
113
  };
@@ -113,20 +117,20 @@ function dayInfoFromScheduleDay(day, open) {
113
117
  result.holiday = day.holiday;
114
118
  if (day.shiftedFrom !== undefined)
115
119
  result.shiftedFrom = day.shiftedFrom;
116
- if (day.rulePath !== undefined)
117
- result.rulePath = day.rulePath;
120
+ if (day.optionPath !== undefined)
121
+ result.optionPath = result.rulePath = day.optionPath;
118
122
  return Object.freeze(result);
119
123
  }
120
- function buildCalendar(lookup, isOpen, info, maxSearchDays) {
124
+ function buildCalendar(lookup, isOpen, info, searchDayLimit) {
121
125
  const dateOf = lookup.dateOf;
122
126
  function search(start, step) {
123
127
  let n = toDayNumber(start);
124
- for (let i = 0; i < maxSearchDays; i++, n += step) {
128
+ for (let i = 0; i < searchDayLimit; i++, n += step) {
125
129
  const date = fromDayNumber(n);
126
130
  if (isOpen(date))
127
131
  return date;
128
132
  }
129
- throw plainError("no-business-day", `No business day found within ${maxSearchDays} days from ${start}`);
133
+ throw plainError("no-business-day", `No business day found within ${searchDayLimit} days from ${start}`);
130
134
  }
131
135
  function countOpen(from, toExclusive) {
132
136
  let count = 0;
@@ -141,16 +145,16 @@ function buildCalendar(lookup, isOpen, info, maxSearchDays) {
141
145
  "modified-following",
142
146
  "modified-preceding",
143
147
  ];
144
- function closingDate(month, closingDay, options) {
145
- return adjustDate(dayOfMonth(month, closingDayIn(month, closingDay)), options);
148
+ function closingDate(month, closingDayOfMonth, options) {
149
+ return adjustDate(dayOfMonth(month, closingDayIn(month, closingDayOfMonth)), options);
146
150
  }
147
- function closingMonthOf(date, closingDay, options) {
148
- checkClosingDay(closingDay);
149
- let month = parseMonth(calendarClosingMonth(date, closingDay));
150
- while (date <= closingDate(shiftMonth(month, -1), closingDay, options)) {
151
+ function closingMonthOf(date, closingDayOfMonth, options) {
152
+ checkClosingDay(closingDayOfMonth);
153
+ let month = parseMonth(calendarClosingMonth(date, closingDayOfMonth));
154
+ while (date <= closingDate(shiftMonth(month, -1), closingDayOfMonth, options)) {
151
155
  month = shiftMonth(month, -1);
152
156
  }
153
- while (date > closingDate(month, closingDay, options))
157
+ while (date > closingDate(month, closingDayOfMonth, options))
154
158
  month = shiftMonth(month, 1);
155
159
  return month;
156
160
  }
@@ -195,7 +199,7 @@ function buildCalendar(lookup, isOpen, info, maxSearchDays) {
195
199
  function businessDaysOfMonth(month) {
196
200
  const { year, month: m } = parseMonth(month);
197
201
  const result = [];
198
- for (let d = 1; d <= daysInMonth(year, m); d++) {
202
+ for (let d = 1; d <= lengthOfMonth(year, m); d++) {
199
203
  const date = formatDate(year, m, d);
200
204
  if (isOpen(date))
201
205
  result.push(date);
@@ -216,16 +220,20 @@ function buildCalendar(lookup, isOpen, info, maxSearchDays) {
216
220
  const calendar = {
217
221
  timeZone: lookup.timeZone,
218
222
  providers: lookup.providers,
219
- outOfRange: lookup.outOfRange,
220
- unconfirmedHolidays: lookup.unconfirmedHolidays,
223
+ outOfRangePolicy: lookup.outOfRangePolicy,
224
+ unconfirmedHolidayPolicy: lookup.unconfirmedHolidayPolicy,
225
+ outOfRange: lookup.outOfRangePolicy,
226
+ unconfirmedHolidays: lookup.unconfirmedHolidayPolicy,
221
227
  dateOf,
222
228
  civilOf: lookup.civilOf,
223
229
  instantOf: lookup.instantOf,
224
230
  today: lookup.today,
225
231
  isHoliday: lookup.isHoliday,
226
- getHoliday: lookup.getHoliday,
232
+ holidayOn: lookup.holidayOn,
233
+ getHoliday: lookup.holidayOn,
227
234
  holidaysInYear: lookup.holidaysInYear,
228
235
  holidaysBetween: lookup.holidaysBetween,
236
+ dayInfoOn: (input) => info(dateOf(input)),
229
237
  dayInfo: (input) => info(dateOf(input)),
230
238
  daysBetween: (from, to) => mapDays(dateOf(from), dateOf(to), info),
231
239
  isBusinessDay: (input) => isOpen(dateOf(input)),
@@ -257,12 +265,12 @@ function buildCalendar(lookup, isOpen, info, maxSearchDays) {
257
265
  }
258
266
  return date;
259
267
  },
260
- businessDaysBetween(from, to) {
268
+ diffBusinessDays(from, to) {
261
269
  const a = toDayNumber(dateOf(from));
262
270
  const b = toDayNumber(dateOf(to));
263
271
  return a <= b ? countOpen(a, b) : -countOpen(b, a);
264
272
  },
265
- listBusinessDays(from, to) {
273
+ businessDatesBetween(from, to) {
266
274
  const a = dateOf(from);
267
275
  const b = dateOf(to);
268
276
  if (a > b)
@@ -279,33 +287,37 @@ function buildCalendar(lookup, isOpen, info, maxSearchDays) {
279
287
  nthBusinessDayOfMonth: nthOfMonth,
280
288
  firstBusinessDayOfMonth: (month) => nthOfMonth(month, 1),
281
289
  lastBusinessDayOfMonth: (month) => nthOfMonth(month, -1),
282
- closingMonth: (input, closingDay, options) => formatMonth(closingMonthOf(dateOf(input), closingDay, options)),
283
- closingPeriod(input, closingDay, options) {
284
- checkClosingDay(closingDay);
290
+ closingMonth: (input, closingDayOfMonth, options) => formatMonth(closingMonthOf(dateOf(input), closingDayOfMonth, options)),
291
+ closingPeriod(input, closingDayOfMonth, options) {
292
+ checkClosingDay(closingDayOfMonth);
285
293
  const isMonth = typeof input === "string" && /^\d{4}-\d{2}$/.test(input);
286
294
  const month = isMonth
287
295
  ? parseMonth(input)
288
- : closingMonthOf(dateOf(input), closingDay, options);
289
- const to = closingDate(month, closingDay, options);
290
- const from = addDays(closingDate(shiftMonth(month, -1), closingDay, options), 1);
296
+ : closingMonthOf(dateOf(input), closingDayOfMonth, options);
297
+ const to = closingDate(month, closingDayOfMonth, options);
298
+ const from = addDays(closingDate(shiftMonth(month, -1), closingDayOfMonth, options), 1);
291
299
  if (from > to) {
292
300
  throw rangeError("no-business-day", `${formatMonth(month)} has no closing period of its own: there is no business day between the previous closing day and ${to} (its days belong to the next month)`);
293
301
  }
294
302
  return Object.freeze({ from, to });
295
303
  },
296
304
  dueDate(month, options) {
297
- const day = options?.day;
305
+ const o = isPlainObject(options) ? renameKeys("throw", ["dueDate"], "", options) : undefined;
306
+ const day = o?.["dayOfMonth"];
298
307
  if (!isDayOfMonthValue(day)) {
299
- throw rangeError("invalid-argument", `day must be an integer from 1 to 31, or -1 (last day): ${String(day)}`);
308
+ throw rangeError("invalid-argument", `dayOfMonth must be an integer from 1 to 31, or -1 (last day): ${String(day)}`);
300
309
  }
301
- return adjustDate(dayOfMonth(parseMonth(month), day), options);
310
+ return adjustDate(dayOfMonth(parseMonth(month), day), o);
302
311
  },
312
+ businessDaysBetween: (from, to) => calendar.diffBusinessDays(from, to),
313
+ listBusinessDays: (from, to) => calendar.businessDatesBetween(from, to),
303
314
  };
304
315
  return Object.freeze(calendar);
305
316
  }
317
+ const isPlainObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
306
318
  const isCalendarLike = (v) => typeof v === "object" &&
307
319
  v !== null &&
308
- typeof v.dayInfo === "function" &&
320
+ typeof v.dayInfoOn === "function" &&
309
321
  typeof v.isBusinessDay === "function" &&
310
322
  typeof v.timeZone === "string" &&
311
323
  Array.isArray(v.providers);
@@ -320,13 +332,16 @@ export function combineCalendars(calendars, options) {
320
332
  throw rangeError("invalid-argument", `calendars[${i}] is the same calendar as calendars[${calendars.indexOf(c)}]`);
321
333
  }
322
334
  });
323
- const mode = options?.businessDay;
335
+ const o = isPlainObject(options)
336
+ ? renameKeys("throw", ["combine"], "", options)
337
+ : {};
338
+ const mode = o["open"];
324
339
  if (mode !== "all" && mode !== "any") {
325
- throw rangeError("invalid-option", 'businessDay must be "all" or "any"');
340
+ throw rangeError("invalid-option", 'open must be "all" or "any"');
326
341
  }
327
- const maxSearchDays = options.maxSearchDays ?? 3660;
328
- if (!Number.isInteger(maxSearchDays) || maxSearchDays < 1) {
329
- throw rangeError("invalid-option", "maxSearchDays must be a positive integer");
342
+ const searchDayLimit = (o["searchDayLimit"] ?? 3660);
343
+ if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
344
+ throw rangeError("invalid-option", "searchDayLimit must be a positive integer");
330
345
  }
331
346
  const zones = [...new Set(calendars.map((c) => c.timeZone))];
332
347
  if (zones.length > 1) {
@@ -340,8 +355,8 @@ export function combineCalendars(calendars, options) {
340
355
  const lookup = createHolidayLookup({
341
356
  providers: Object.freeze(providers),
342
357
  timeZone: zones[0],
343
- outOfRange: calendars.every((c) => c.outOfRange === "ignore") ? "ignore" : "throw",
344
- unconfirmedHolidays: calendars.some((c) => c.unconfirmedHolidays === "throw")
358
+ outOfRangePolicy: calendars.every((c) => c.outOfRangePolicy === "ignore") ? "ignore" : "throw",
359
+ unconfirmedHolidayPolicy: calendars.some((c) => c.unconfirmedHolidayPolicy === "throw")
345
360
  ? "throw"
346
361
  : "accept",
347
362
  });
@@ -349,30 +364,31 @@ export function combineCalendars(calendars, options) {
349
364
  ? calendars.every((c) => c.isBusinessDay(date))
350
365
  : calendars.some((c) => c.isBusinessDay(date));
351
366
  function info(date) {
352
- const results = calendars.map((c) => c.dayInfo(date));
353
- const open = mode === "all" ? results.every((r) => r.businessDay) : results.some((r) => r.businessDay);
354
- const decidedBy = results.findIndex((r) => r.businessDay === open);
367
+ const results = calendars.map((c) => c.dayInfoOn(date));
368
+ const open = mode === "all" ? results.every((r) => r.open) : results.some((r) => r.open);
369
+ const decidedBy = results.findIndex((r) => r.open === open);
355
370
  const base = results[decidedBy];
356
371
  const result = {
357
372
  date,
358
373
  weekday: base.weekday,
374
+ open,
359
375
  businessDay: open,
360
376
  reason: base.reason,
361
377
  };
362
378
  if (base.name !== undefined)
363
379
  result.name = base.name;
364
- const holiday = lookup.holidayOn(date);
380
+ const holiday = lookup.holidayOfDate(date);
365
381
  if (holiday !== undefined)
366
382
  result.holiday = holiday;
367
383
  if (base.shiftedFrom !== undefined)
368
384
  result.shiftedFrom = base.shiftedFrom;
369
- if (base.rulePath !== undefined)
370
- result.rulePath = base.rulePath;
385
+ if (base.optionPath !== undefined)
386
+ result.optionPath = result.rulePath = base.optionPath;
371
387
  result.decidedBy = decidedBy;
372
388
  result.decidedByPath = Object.freeze([decidedBy, ...(base.decidedByPath ?? [])]);
373
389
  return Object.freeze(result);
374
390
  }
375
- return buildCalendar(lookup, isOpen, info, maxSearchDays);
391
+ return buildCalendar(lookup, isOpen, info, searchDayLimit);
376
392
  }
377
393
  export function createCalendarFromSchedule(schedule, isOpen, options) {
378
394
  const info = infoOfSchedule(schedule);
@@ -382,13 +398,16 @@ export function createCalendarFromSchedule(schedule, isOpen, options) {
382
398
  if (typeof isOpen !== "function") {
383
399
  throw rangeError("invalid-argument", "isOpen must be a function (value) => boolean");
384
400
  }
385
- const maxSearchDays = options?.maxSearchDays ?? 3660;
386
- if (!Number.isInteger(maxSearchDays) || maxSearchDays < 1) {
387
- throw rangeError("invalid-option", "maxSearchDays must be a positive integer");
401
+ const o = isPlainObject(options)
402
+ ? renameKeys("throw", ["fromSchedule"], "", options)
403
+ : {};
404
+ const searchDayLimit = (o["searchDayLimit"] ?? 3660);
405
+ if (!Number.isInteger(searchDayLimit) || searchDayLimit < 1) {
406
+ throw rangeError("invalid-option", "searchDayLimit must be a positive integer");
388
407
  }
389
408
  const open = (date) => isOpen(info(date).value) === true;
390
409
  return buildCalendar(schedule, open, (date) => {
391
410
  const day = info(date);
392
- return dayInfoFromScheduleDay(day, isOpen(day.value) === true);
393
- }, maxSearchDays);
411
+ return dayInfoFromScheduleDay(day, isOpen(day.value) === true, true);
412
+ }, searchDayLimit);
394
413
  }
@@ -24,13 +24,13 @@ export declare function parseDate(value: string): {
24
24
  * "YYYY-MM-DD" として正しい暦日か。
25
25
  * @public
26
26
  */
27
- export declare function isValidDate(value: unknown): value is DateString;
27
+ export declare function isValidDate(input: unknown): input is DateString;
28
28
  /** 年月日から "YYYY-MM-DD" を作る(範囲外なら RangeError) */
29
29
  export declare function formatDate(year: number, month: number, day: number): DateString;
30
30
  /** うるう年か */
31
31
  export declare function isLeapYear(year: number): boolean;
32
32
  /** その月の日数 */
33
- export declare function daysInMonth(year: number, month: number): number;
33
+ export declare function lengthOfMonth(year: number, month: number): number;
34
34
  /** 1970-01-01 からの日数 */
35
35
  export declare function toDayNumber(date: DateString): number;
36
36
  /** 1970-01-01 からの日数を "YYYY-MM-DD" に戻す */
@@ -39,7 +39,7 @@ export declare function fromDayNumber(dayNumber: number): DateString;
39
39
  * n 日後(負なら前)の日付。
40
40
  * @public
41
41
  */
42
- export declare function addDays(date: DateString, days: number): DateString;
42
+ export declare function addDays(date: DateString, n: number): DateString;
43
43
  /**
44
44
  * from から to までの日数(to が後なら正)。
45
45
  * @public
package/dist/core/date.js CHANGED
@@ -10,16 +10,16 @@ export function parseDate(value) {
10
10
  const year = Number(m[1]);
11
11
  const month = Number(m[2]);
12
12
  const day = Number(m[3]);
13
- if (year < 1000 || month < 1 || month > 12 || day < 1 || day > daysInMonth(year, month)) {
13
+ if (year < 1000 || month < 1 || month > 12 || day < 1 || day > lengthOfMonth(year, month)) {
14
14
  throw rangeError("invalid-date", `Invalid date: ${value}`);
15
15
  }
16
16
  return { year, month, day };
17
17
  }
18
- export function isValidDate(value) {
19
- if (typeof value !== "string")
18
+ export function isValidDate(input) {
19
+ if (typeof input !== "string")
20
20
  return false;
21
21
  try {
22
- parseDate(value);
22
+ parseDate(input);
23
23
  return true;
24
24
  }
25
25
  catch {
@@ -37,7 +37,7 @@ export function formatDate(year, month, day) {
37
37
  export function isLeapYear(year) {
38
38
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
39
39
  }
40
- export function daysInMonth(year, month) {
40
+ export function lengthOfMonth(year, month) {
41
41
  if (month === 2)
42
42
  return isLeapYear(year) ? 29 : 28;
43
43
  const days = MONTH_DAYS[month - 1];
@@ -53,11 +53,11 @@ export function fromDayNumber(dayNumber) {
53
53
  const d = new Date(dayNumber * MS_PER_DAY);
54
54
  return formatDate(d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate());
55
55
  }
56
- export function addDays(date, days) {
57
- if (!Number.isInteger(days)) {
58
- throw rangeError("invalid-argument", `days must be an integer: ${days}`);
56
+ export function addDays(date, n) {
57
+ if (!Number.isInteger(n)) {
58
+ throw rangeError("invalid-argument", `n must be an integer: ${n}`);
59
59
  }
60
- return fromDayNumber(toDayNumber(date) + days);
60
+ return fromDayNumber(toDayNumber(date) + n);
61
61
  }
62
62
  export function diffDays(from, to) {
63
63
  return toDayNumber(to) - toDayNumber(from);
@@ -11,12 +11,12 @@
11
11
  * never-matches … 当てはまる日がない繰り返しの規則(2 月 30 日、有効期間の中に第 5 水曜日がない、提供元のない設定の祝日の翌日・祝前日、など)
12
12
  * out-of-range … 個別の日付、または規則の有効期間が祝日の提供元の対応年の外にある(relatedPath に提供元)
13
13
  * no-business-day … 営業日が 1 日もない設定(営業日カレンダーのみ)
14
- * - info … redundant: 取り除いても結果が変わらない規則・設定(判定に祝日を使わない設定の unconfirmedHolidays: "throw" を含む)
14
+ * - info … redundant: 取り除いても結果が変わらない規則・設定(判定に祝日を使わない設定の unconfirmedHolidayPolicy: "throw" を含む)
15
15
  * expired: 第 2 引数の asOf より前に終わった規則・日付(asOf を渡したときだけ)
16
16
  * counting-basis: 第 n 営業日の規則(businessDayOfMonth)の数える基準は繰り返しの規則を除くので、
17
17
  * 同じ設定の毎週の曜日の規則({ weekday })の曜日は営業日として数えられる(relatedPath にその規則)
18
18
  *
19
- * 未確定の祝日の扱い(unconfirmedHolidays)は診断では常に "accept" で評価する。診断は設定の形を調べるもので、
19
+ * 未確定の祝日の扱い(unconfirmedHolidayPolicy)は診断では常に "accept" で評価する。診断は設定の形を調べるもので、
20
20
  * 祝日が確定しているかどうかは関係がなく、"throw" のまま評価すると例外を握りつぶして「当てはまらない」と誤判定するため
21
21
  *
22
22
  * 判定の順番(個別の日付 → 毎年の月日 → 繰り返し(over)→ 祝日 → 繰り返し(under・振替先)→ 曜日)は
@@ -46,6 +46,8 @@ export type DiagnosticSeverity = "error" | "warning" | "info";
46
46
  export type KnownDiagnosticCode = KnownErrorCode
47
47
  /** 知らないキー(作成時は無視される) */
48
48
  | "unknown-option"
49
+ /** 0.30.0 で改名した旧名のキー・値(新しい名前と同じに扱う。1.0.0 で invalid-option になる) */
50
+ | "deprecated-option"
49
51
  /** 同じ種類の先の規則に完全に覆われ、決して使われない */
50
52
  | "shadowed"
51
53
  /** 当てはまる日がない繰り返しの規則 */
@@ -68,7 +70,7 @@ export type DiagnosticCode = KnownDiagnosticCode | (string & {});
68
70
  export interface Diagnostic {
69
71
  readonly severity: DiagnosticSeverity;
70
72
  readonly code: DiagnosticCode;
71
- /** 設定の中の位置(例: "closedRecurring[1]"・"closedDates[0].date")。設定全体なら "" */
73
+ /** 設定の中の位置(例: "closedRecurringRules[1]"・"closedDates[0].date")。設定全体なら "" */
72
74
  readonly path: string;
73
75
  readonly message: string;
74
76
  /** 関係する別の位置(shadowed では覆っている先の規則、out-of-range では祝日の提供元) */