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.
- package/CHANGELOG.md +46 -1
- package/README.md +14 -13
- package/dist/core/calendar.d.ts +77 -33
- package/dist/core/calendar.js +91 -72
- package/dist/core/date.d.ts +3 -3
- package/dist/core/date.js +9 -9
- package/dist/core/diagnose.d.ts +5 -3
- package/dist/core/diagnose.js +49 -29
- package/dist/core/errors.d.ts +2 -2
- package/dist/core/input.d.ts +3 -0
- package/dist/core/migrate.d.ts +37 -0
- package/dist/core/migrate.js +95 -0
- package/dist/core/month.d.ts +5 -5
- package/dist/core/month.js +16 -16
- package/dist/core/renamed.d.ts +42 -0
- package/dist/core/renamed.js +73 -0
- package/dist/core/schedule.d.ts +259 -101
- package/dist/core/schedule.js +138 -91
- package/dist/core/types.d.ts +1 -1
- package/dist/diagnose/index.d.ts +1 -0
- package/dist/diagnose/index.js +1 -0
- package/dist/fr/index.d.ts +1 -1
- package/dist/fr/rules.d.ts +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/jp/index.d.ts +33 -8
- package/dist/jp/index.js +6 -3
- package/dist/jp/rules.d.ts +8 -7
- package/dist/jp/rules.js +1 -1
- package/dist/provider/index.d.ts +35 -13
- package/dist/provider/index.js +16 -12
- package/dist/sg/rules.d.ts +1 -0
- package/dist/uk/rules.d.ts +1 -0
- package/dist/uk/rules.js +2 -2
- package/package.json +2 -2
package/dist/core/schedule.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 1 日の値は次の優先順位で決まる(上が優先):
|
|
5
5
|
* 1. dates … 個別の日付・期間(配列で先に書いたものが優先)
|
|
6
6
|
* 2. annual … 毎年の月日・月日の期間(年をまたぐ期間も可。配列で先に書いたものが優先)
|
|
7
|
-
* 3. recurring(
|
|
7
|
+
* 3. recurring(holidayOverlapPolicy: "over-holiday")… 祝日でも当てはめる繰り返しの規則
|
|
8
8
|
* 4. 祝日 … holiday の規則("weekday": 曜日どおり / { sameAs: 曜日 }: その曜日の値 / { value }: 指定の値)
|
|
9
9
|
* 5. recurring("under-holiday"・"after-holiday" の振替先)… 繰り返しの規則(配列で先に書いたものが優先)
|
|
10
10
|
* 6. weekly … 曜日ごとの値
|
|
@@ -25,19 +25,19 @@ export type { CivilDateTimeParts } from "./input.ts";
|
|
|
25
25
|
import { type Holiday, type HolidayProvider } from "./types.ts";
|
|
26
26
|
import type { Calendar } from "./calendar.ts";
|
|
27
27
|
/**
|
|
28
|
-
* 祝日の値の決め方(スケジュールの
|
|
28
|
+
* 祝日の値の決め方(スケジュールの holidayPolicy の設定)。
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export type
|
|
31
|
+
export type ScheduleHolidayPolicy<Value> =
|
|
32
32
|
/** 祝日を考えず、曜日の値を使う */
|
|
33
|
-
"
|
|
33
|
+
"ignore"
|
|
34
34
|
/** 指定した曜日の値を使う(例: 祝日は日曜日の営業時間) */
|
|
35
35
|
| {
|
|
36
36
|
readonly sameAs: Weekday;
|
|
37
37
|
}
|
|
38
38
|
/** 指定した値を使う */
|
|
39
39
|
| {
|
|
40
|
-
readonly value:
|
|
40
|
+
readonly value: Value;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* 月の第 n 回目(1〜5)。-1 は最終(その月の最後のその曜日)。
|
|
@@ -54,6 +54,11 @@ export type DayOfMonth = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
|
|
|
54
54
|
* @public
|
|
55
55
|
*/
|
|
56
56
|
export type BusinessDayOfMonth = number;
|
|
57
|
+
/**
|
|
58
|
+
* 週の第 n 営業日(1〜7、-1 は最後、-2 はその前 … -7)。
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export type BusinessDayOfWeek = 1 | 2 | 3 | 4 | 5 | 6 | 7 | -1 | -2 | -3 | -4 | -5 | -6 | -7;
|
|
57
62
|
/**
|
|
58
63
|
* 月(1〜12)。
|
|
59
64
|
* @public
|
|
@@ -66,7 +71,7 @@ export type Month = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
|
66
71
|
* - "after-holiday": 祝日の後。祝日には当てはめず、その日以降で最初の祝日でない日(土曜日のこともある)に振り替える
|
|
67
72
|
* @public
|
|
68
73
|
*/
|
|
69
|
-
export type
|
|
74
|
+
export type HolidayOverlapPolicy = "under-holiday" | "over-holiday" | "after-holiday";
|
|
70
75
|
/**
|
|
71
76
|
* 規則の有効期間(両端を含む "YYYY-MM-DD")。期間の外では、その規則は書かれていないのと同じに扱う。
|
|
72
77
|
* @public
|
|
@@ -96,13 +101,12 @@ export interface WeekdayPattern {
|
|
|
96
101
|
/** 当てはめる月(省略時はすべての月) */
|
|
97
102
|
readonly months?: readonly Month[];
|
|
98
103
|
/**
|
|
99
|
-
*
|
|
104
|
+
* holidayOverlapPolicy: "after-holiday" と組で、祝日に加えて飛ばす曜日(0 = 日曜日〜6 = 土曜日)。
|
|
100
105
|
* 本来の日が祝日かこの曜日なら、その日以降で最初の、祝日でもこの曜日でもない日に振り替える
|
|
101
|
-
* (例: 月曜定休で、月曜が祝日なら翌平日(土曜日には落とさない)は { weekday: 1,
|
|
106
|
+
* (例: 月曜定休で、月曜が祝日なら翌平日(土曜日には落とさない)は { weekday: 1, holidayOverlapPolicy: "after-holiday", skipWeekdays: [6] })。
|
|
102
107
|
* weekday 自身は含められない。"after-holiday" 以外と組にすると invalid-option
|
|
103
108
|
*/
|
|
104
|
-
readonly
|
|
105
|
-
readonly day?: never;
|
|
109
|
+
readonly dayOfMonth?: never;
|
|
106
110
|
readonly businessDayOfMonth?: never;
|
|
107
111
|
readonly calendar?: never;
|
|
108
112
|
readonly dayAfterHoliday?: never;
|
|
@@ -113,6 +117,8 @@ export interface WeekdayPattern {
|
|
|
113
117
|
readonly keys?: never;
|
|
114
118
|
readonly cycle?: never;
|
|
115
119
|
readonly positions?: never;
|
|
120
|
+
readonly businessDayOfWeek?: never;
|
|
121
|
+
readonly weekStart?: never;
|
|
116
122
|
}
|
|
117
123
|
/**
|
|
118
124
|
* 毎月の日の繰り返し(例: 毎月 20 日、毎月末日)。その月にない日(2 月 30 日など)は当てはまらない。
|
|
@@ -120,15 +126,14 @@ export interface WeekdayPattern {
|
|
|
120
126
|
*/
|
|
121
127
|
export interface DayOfMonthPattern {
|
|
122
128
|
/** 月の日(1〜31、-1 は末日)。配列で複数指定できる */
|
|
123
|
-
readonly
|
|
129
|
+
readonly dayOfMonth: DayOfMonth | readonly DayOfMonth[];
|
|
124
130
|
/** 当てはめる月(省略時はすべての月) */
|
|
125
131
|
readonly months?: readonly Month[];
|
|
126
132
|
/**
|
|
127
|
-
*
|
|
133
|
+
* holidayOverlapPolicy: "after-holiday" と組で、祝日に加えて飛ばす曜日。本来の日が祝日かこの曜日なら、その日以降で最初の、
|
|
128
134
|
* 祝日でもこの曜日でもない日に振り替える(例: 「6 月 15 日は創立記念日。土日祝なら翌営業日」は
|
|
129
|
-
* { day: 15, months: [6],
|
|
135
|
+
* { day: 15, months: [6], holidayOverlapPolicy: "after-holiday", skipWeekdays: [0, 6] })。"after-holiday" 以外と組にすると invalid-option
|
|
130
136
|
*/
|
|
131
|
-
readonly skipWeekdays?: readonly Weekday[];
|
|
132
137
|
readonly weekday?: never;
|
|
133
138
|
readonly nth?: never;
|
|
134
139
|
readonly interval?: never;
|
|
@@ -143,21 +148,23 @@ export interface DayOfMonthPattern {
|
|
|
143
148
|
readonly keys?: never;
|
|
144
149
|
readonly cycle?: never;
|
|
145
150
|
readonly positions?: never;
|
|
151
|
+
readonly businessDayOfWeek?: never;
|
|
152
|
+
readonly weekStart?: never;
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
155
|
* 月の第 n 営業日(例: 月末最終営業日、第 5 営業日)。n は 1〜31、-1 は最後、-2 はその前。その月にない回は当てはまらない。
|
|
149
156
|
*
|
|
150
157
|
* 数える基準はこの規則を書いたカレンダーの「繰り返しの規則をすべて除いた判定」(個別の日付 → 毎年の月日 → 祝日 → 定休日の曜日)で、
|
|
151
|
-
* 定休日の曜日・祝日・年末年始休業(
|
|
158
|
+
* 定休日の曜日・祝日・年末年始休業(closedAnnualDates)・臨時休業日は数えに入らない。繰り返しの規則(定休日を closedRecurringRules の
|
|
152
159
|
* 曜日の規則で書いたものを含む)は基準に入らない。nthBusinessDayOfMonth・lastBusinessDayOfMonth はこの規則を適用した後の
|
|
153
160
|
* 実際の営業日を返すので、{ businessDayOfMonth: -1 } を休業にすると lastBusinessDayOfMonth はその前日になる。
|
|
154
|
-
*
|
|
161
|
+
* holidayOverlapPolicy は "under-holiday"(既定)と "over-holiday" を受け、"after-holiday" は invalid-option(第 n 営業日をずらす意味がない)。
|
|
155
162
|
* holidayPolicy: "open" のカレンダーでは祝日も営業日として数えるので第 n 営業日が祝日に当たることがあり、既定ではその日は
|
|
156
163
|
* 祝日の段階が先に決めてこの規則は当てはまらない(曜日の規則と同じ優先順位)。「第 1 営業日は祝日でも休業」は "over-holiday" で書く。
|
|
157
164
|
* holidayPolicy: "closed" では祝日が基準の営業日にならないので "over-holiday" は結果を変えない(診断が info で知らせる)。
|
|
158
165
|
*
|
|
159
166
|
* スケジュール(createSchedule の recurring)では、スケジュール自身に営業・休業の概念がないので、数える基準にする作成済みの
|
|
160
|
-
* カレンダーを calendar で指定する(必須。タイムゾーンはスケジュールと同じであること)。カレンダー(
|
|
167
|
+
* カレンダーを calendar で指定する(必須。タイムゾーンはスケジュールと同じであること)。カレンダー(closedRecurringRules・openRecurringRules)
|
|
161
168
|
* では calendar は指定できない(invalid-option。基準は自分の設定で決まる)。
|
|
162
169
|
* @public
|
|
163
170
|
*/
|
|
@@ -172,7 +179,42 @@ export interface BusinessDayOfMonthPattern {
|
|
|
172
179
|
readonly nth?: never;
|
|
173
180
|
readonly interval?: never;
|
|
174
181
|
readonly anchor?: never;
|
|
175
|
-
readonly
|
|
182
|
+
readonly dayOfMonth?: never;
|
|
183
|
+
readonly dayAfterHoliday?: never;
|
|
184
|
+
readonly dayBeforeHoliday?: never;
|
|
185
|
+
readonly holiday?: never;
|
|
186
|
+
readonly weekdays?: never;
|
|
187
|
+
readonly kinds?: never;
|
|
188
|
+
readonly keys?: never;
|
|
189
|
+
readonly skipWeekdays?: never;
|
|
190
|
+
readonly cycle?: never;
|
|
191
|
+
readonly positions?: never;
|
|
192
|
+
readonly businessDayOfWeek?: never;
|
|
193
|
+
readonly weekStart?: never;
|
|
194
|
+
/** 祝日に当たったときの扱い(既定: "under-holiday"。"after-holiday" は受けない) */
|
|
195
|
+
readonly holidayOverlapPolicy?: "under-holiday" | "over-holiday";
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* 週の第 n 営業日(例: 週の最終営業日、週の最初の営業日)。週は weekStart の曜日から 7 日間で、n は 1〜7、-1 は最後、-2 はその前。
|
|
199
|
+
* その週にない回は当てはまらない。数える基準・calendar・holidayOverlapPolicy の扱いは businessDayOfMonth と同じ
|
|
200
|
+
* (カレンダーでは自分の設定の「繰り返しの規則をすべて除いた判定」、スケジュールでは必須の calendar で数える)。
|
|
201
|
+
* 週の始まりは地域・業種で違うので、weekStart は省略できない。months は当てはまる日の月で絞る。
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export interface BusinessDayOfWeekPattern {
|
|
205
|
+
readonly businessDayOfWeek: BusinessDayOfWeek | readonly BusinessDayOfWeek[];
|
|
206
|
+
/** 週の始まりの曜日(0 = 日曜日〜6 = 土曜日) */
|
|
207
|
+
readonly weekStart: Weekday;
|
|
208
|
+
readonly months?: readonly Month[];
|
|
209
|
+
readonly calendar?: Calendar;
|
|
210
|
+
/** 祝日に当たったときの扱い(既定: "under-holiday"。"after-holiday" は受けない) */
|
|
211
|
+
readonly holidayOverlapPolicy?: "under-holiday" | "over-holiday";
|
|
212
|
+
readonly weekday?: never;
|
|
213
|
+
readonly nth?: never;
|
|
214
|
+
readonly interval?: never;
|
|
215
|
+
readonly anchor?: never;
|
|
216
|
+
readonly dayOfMonth?: never;
|
|
217
|
+
readonly businessDayOfMonth?: never;
|
|
176
218
|
readonly dayAfterHoliday?: never;
|
|
177
219
|
readonly dayBeforeHoliday?: never;
|
|
178
220
|
readonly holiday?: never;
|
|
@@ -186,7 +228,7 @@ export interface BusinessDayOfMonthPattern {
|
|
|
186
228
|
/**
|
|
187
229
|
* 祝日の翌日(祝日が続く場合は連休が明けた日。その日自身は祝日でない)。「祝日」は提供元の祝日だけ。
|
|
188
230
|
* kinds・keys で、前日の祝日(skipWeekdays があれば、飛ばした日の手前で最も近い祝日)の種別・識別子を絞れる。
|
|
189
|
-
* 当てはまる日は祝日でないので、
|
|
231
|
+
* 当てはまる日は祝日でないので、holidayOverlapPolicy は指定できない(指定すると invalid-option)。
|
|
190
232
|
* @public
|
|
191
233
|
*/
|
|
192
234
|
export interface DayAfterHolidayPattern<Kind extends string = string> {
|
|
@@ -208,20 +250,23 @@ export interface DayAfterHolidayPattern<Kind extends string = string> {
|
|
|
208
250
|
readonly nth?: never;
|
|
209
251
|
readonly interval?: never;
|
|
210
252
|
readonly anchor?: never;
|
|
211
|
-
readonly
|
|
253
|
+
readonly dayOfMonth?: never;
|
|
212
254
|
readonly businessDayOfMonth?: never;
|
|
213
255
|
readonly calendar?: never;
|
|
214
256
|
readonly dayBeforeHoliday?: never;
|
|
215
257
|
readonly holiday?: never;
|
|
216
258
|
readonly cycle?: never;
|
|
217
259
|
readonly positions?: never;
|
|
260
|
+
readonly businessDayOfWeek?: never;
|
|
261
|
+
readonly weekStart?: never;
|
|
262
|
+
readonly holidayOverlapPolicy?: never;
|
|
218
263
|
}
|
|
219
264
|
/**
|
|
220
265
|
* 祝前日(翌日が祝日で、その日自身は祝日でない日。連休なら連休の初日の前日)。「祝日」は提供元の祝日だけ。
|
|
221
266
|
* 祝日の翌日(dayAfterHoliday)の鏡像で、祝前日料金・祝前日の営業時間の延長・締め時刻の繰り上げなどを規則として書く。
|
|
222
267
|
* kinds・keys で、翌日の祝日(skipWeekdays があれば、飛ばした日の先で最も近い祝日)の種別・識別子を絞れる
|
|
223
268
|
* (例: 旧正月の前日は { dayBeforeHoliday: true, keys: ["chinese-new-year"] })。
|
|
224
|
-
* 当てはまる日は祝日でないので、
|
|
269
|
+
* 当てはまる日は祝日でないので、holidayOverlapPolicy は指定できない(指定すると invalid-option)。
|
|
225
270
|
* @public
|
|
226
271
|
*/
|
|
227
272
|
export interface DayBeforeHolidayPattern<Kind extends string = string> {
|
|
@@ -243,19 +288,22 @@ export interface DayBeforeHolidayPattern<Kind extends string = string> {
|
|
|
243
288
|
readonly nth?: never;
|
|
244
289
|
readonly interval?: never;
|
|
245
290
|
readonly anchor?: never;
|
|
246
|
-
readonly
|
|
291
|
+
readonly dayOfMonth?: never;
|
|
247
292
|
readonly businessDayOfMonth?: never;
|
|
248
293
|
readonly calendar?: never;
|
|
249
294
|
readonly dayAfterHoliday?: never;
|
|
250
295
|
readonly holiday?: never;
|
|
251
296
|
readonly cycle?: never;
|
|
252
297
|
readonly positions?: never;
|
|
298
|
+
readonly businessDayOfWeek?: never;
|
|
299
|
+
readonly weekStart?: never;
|
|
300
|
+
readonly holidayOverlapPolicy?: never;
|
|
253
301
|
}
|
|
254
302
|
/**
|
|
255
303
|
* 日単位の周期(例: 4 勤 2 休の交替制の休日、10 日に 1 度の定期点検)。週や月にそろわない周期を、起点からの日数で書く。
|
|
256
304
|
* 起点(anchor)を 1 日目として cycle 日ごとに繰り返し、positions に書いた何日目かに当てはまる
|
|
257
305
|
* (例: 4 勤 2 休の休日は { cycle: 6, anchor: "2026-01-05", positions: [5, 6] })。起点より前の日にも当てはまるので、
|
|
258
|
-
* 起点から始めるには effectiveFrom を併せて指定する。
|
|
306
|
+
* 起点から始めるには effectiveFrom を併せて指定する。holidayOverlapPolicy は "under-holiday"(既定)と "over-holiday" を受け、
|
|
259
307
|
* "after-holiday" は invalid-option(周期の日を祝日の後ろへずらす意味がない)。
|
|
260
308
|
* @public
|
|
261
309
|
*/
|
|
@@ -271,7 +319,7 @@ export interface CyclePattern {
|
|
|
271
319
|
readonly weekday?: never;
|
|
272
320
|
readonly nth?: never;
|
|
273
321
|
readonly interval?: never;
|
|
274
|
-
readonly
|
|
322
|
+
readonly dayOfMonth?: never;
|
|
275
323
|
readonly businessDayOfMonth?: never;
|
|
276
324
|
readonly calendar?: never;
|
|
277
325
|
readonly dayAfterHoliday?: never;
|
|
@@ -281,12 +329,16 @@ export interface CyclePattern {
|
|
|
281
329
|
readonly kinds?: never;
|
|
282
330
|
readonly keys?: never;
|
|
283
331
|
readonly skipWeekdays?: never;
|
|
332
|
+
readonly businessDayOfWeek?: never;
|
|
333
|
+
readonly weekStart?: never;
|
|
334
|
+
/** 祝日に当たったときの扱い(既定: "under-holiday"。"after-holiday" は受けない) */
|
|
335
|
+
readonly holidayOverlapPolicy?: "under-holiday" | "over-holiday";
|
|
284
336
|
}
|
|
285
337
|
/**
|
|
286
338
|
* 祝日(提供元の祝日である日)。kinds で祝日の種別を、keys で個別の祝日を絞れる(省略時はすべての祝日)。
|
|
287
339
|
* 「祝日の上」の段階(holidayPolicy・スケジュールの holiday より先)で判定し、祝日の既定の扱いの例外を書く
|
|
288
340
|
* (例: 「2027 年 4 月から祝日も営業」「振替休日は診療」「5 月の祝日は特別営業時間」)。
|
|
289
|
-
* 当てはまる日は祝日なので、
|
|
341
|
+
* 当てはまる日は祝日なので、holidayOverlapPolicy は指定できない(指定すると invalid-option)。
|
|
290
342
|
* @public
|
|
291
343
|
*/
|
|
292
344
|
export interface HolidayPattern<Kind extends string = string> {
|
|
@@ -309,7 +361,7 @@ export interface HolidayPattern<Kind extends string = string> {
|
|
|
309
361
|
readonly nth?: never;
|
|
310
362
|
readonly interval?: never;
|
|
311
363
|
readonly anchor?: never;
|
|
312
|
-
readonly
|
|
364
|
+
readonly dayOfMonth?: never;
|
|
313
365
|
readonly businessDayOfMonth?: never;
|
|
314
366
|
readonly calendar?: never;
|
|
315
367
|
readonly dayAfterHoliday?: never;
|
|
@@ -317,64 +369,93 @@ export interface HolidayPattern<Kind extends string = string> {
|
|
|
317
369
|
readonly skipWeekdays?: never;
|
|
318
370
|
readonly cycle?: never;
|
|
319
371
|
readonly positions?: never;
|
|
372
|
+
readonly businessDayOfWeek?: never;
|
|
373
|
+
readonly weekStart?: never;
|
|
374
|
+
readonly holidayOverlapPolicy?: never;
|
|
320
375
|
}
|
|
321
376
|
/**
|
|
322
|
-
*
|
|
377
|
+
* 繰り返しのパターン。曜日・日の規則は、"after-holiday" のときだけ skipWeekdays を書ける。
|
|
323
378
|
* @public
|
|
324
379
|
*/
|
|
325
|
-
export type RecurringPattern<Kind extends string = string> = WeekdayPattern
|
|
380
|
+
export type RecurringPattern<Kind extends string = string> = (WeekdayPattern & ({
|
|
381
|
+
/** 祝日に当たったら、その日以降で最初の祝日でない日に振り替える */
|
|
382
|
+
readonly holidayOverlapPolicy: "after-holiday";
|
|
383
|
+
/** 振替先を探すときに、祝日に加えて飛ばす曜日 */
|
|
384
|
+
readonly skipWeekdays?: readonly Weekday[];
|
|
385
|
+
} | {
|
|
386
|
+
/** 祝日に当たったときの扱い(既定: "under-holiday") */
|
|
387
|
+
readonly holidayOverlapPolicy?: "under-holiday" | "over-holiday";
|
|
388
|
+
readonly skipWeekdays?: never;
|
|
389
|
+
})) | (DayOfMonthPattern & ({
|
|
390
|
+
/** 祝日に当たったら、その日以降で最初の祝日でない日に振り替える */
|
|
391
|
+
readonly holidayOverlapPolicy: "after-holiday";
|
|
392
|
+
/** 振替先を探すときに、祝日に加えて飛ばす曜日 */
|
|
393
|
+
readonly skipWeekdays?: readonly Weekday[];
|
|
394
|
+
} | {
|
|
395
|
+
/** 祝日に当たったときの扱い(既定: "under-holiday") */
|
|
396
|
+
readonly holidayOverlapPolicy?: "under-holiday" | "over-holiday";
|
|
397
|
+
readonly skipWeekdays?: never;
|
|
398
|
+
})) | BusinessDayOfMonthPattern | BusinessDayOfWeekPattern | DayAfterHolidayPattern<Kind> | DayBeforeHolidayPattern<Kind> | HolidayPattern<Kind> | CyclePattern;
|
|
326
399
|
/**
|
|
327
|
-
* 繰り返しの規則(営業日カレンダーの
|
|
400
|
+
* 繰り返しの規則(営業日カレンダーの closedRecurringRules・openRecurringRules)。
|
|
401
|
+
* 第 n 営業日の規則は calendar を指定できない(数える基準は自分の設定)。
|
|
328
402
|
* @public
|
|
329
403
|
*/
|
|
330
|
-
export type RecurringRule<Kind extends string = string> = RecurringPattern<Kind>
|
|
404
|
+
export type RecurringRule<Kind extends string = string> = (Exclude<RecurringPattern<Kind>, BusinessDayOfMonthPattern | BusinessDayOfWeekPattern> | ((BusinessDayOfMonthPattern | BusinessDayOfWeekPattern) & {
|
|
405
|
+
readonly calendar?: never;
|
|
406
|
+
})) & EffectivePeriod & {
|
|
331
407
|
readonly name?: string;
|
|
332
|
-
/**
|
|
333
|
-
readonly onHolidayRule?:
|
|
408
|
+
/** @deprecated 0.30.0 で holidayOverlapPolicy に改名した。1.0.0 で削除する */
|
|
409
|
+
readonly onHolidayRule?: HolidayOverlapPolicy;
|
|
334
410
|
};
|
|
335
411
|
/**
|
|
336
|
-
* 繰り返しの規則の値(スケジュールの
|
|
412
|
+
* 繰り返しの規則の値(スケジュールの recurringRules)。第 n 営業日の規則は、数える基準のカレンダー calendar が必須。
|
|
337
413
|
* @public
|
|
338
414
|
*/
|
|
339
|
-
export type
|
|
340
|
-
readonly
|
|
415
|
+
export type ScheduleRecurringRule<Value, Kind extends string = string> = (Exclude<RecurringPattern<Kind>, BusinessDayOfMonthPattern | BusinessDayOfWeekPattern> | ((BusinessDayOfMonthPattern | BusinessDayOfWeekPattern) & {
|
|
416
|
+
readonly calendar: Calendar;
|
|
417
|
+
})) & EffectivePeriod & {
|
|
418
|
+
readonly name?: string;
|
|
419
|
+
/** @deprecated 0.30.0 で holidayOverlapPolicy に改名した。1.0.0 で削除する */
|
|
420
|
+
readonly onHolidayRule?: HolidayOverlapPolicy;
|
|
421
|
+
readonly value: Value;
|
|
341
422
|
};
|
|
342
423
|
/**
|
|
343
424
|
* 毎年の月日 "MM-DD" の値。
|
|
344
425
|
* @public
|
|
345
426
|
*/
|
|
346
|
-
export interface
|
|
427
|
+
export interface ScheduleAnnualDate<Value> extends EffectivePeriod {
|
|
347
428
|
readonly date: string;
|
|
348
|
-
readonly value:
|
|
429
|
+
readonly value: Value;
|
|
349
430
|
readonly name?: string;
|
|
350
431
|
}
|
|
351
432
|
/**
|
|
352
433
|
* 毎年の月日の期間の値(from > to なら年をまたぐ。例: 12-31 〜 01-03)。
|
|
353
434
|
* @public
|
|
354
435
|
*/
|
|
355
|
-
export interface
|
|
436
|
+
export interface ScheduleAnnualRange<Value> extends EffectivePeriod {
|
|
356
437
|
readonly from: string;
|
|
357
438
|
readonly to: string;
|
|
358
|
-
readonly value:
|
|
439
|
+
readonly value: Value;
|
|
359
440
|
readonly name?: string;
|
|
360
441
|
}
|
|
361
442
|
/**
|
|
362
443
|
* 個別の日付 "YYYY-MM-DD" の値。
|
|
363
444
|
* @public
|
|
364
445
|
*/
|
|
365
|
-
export interface
|
|
446
|
+
export interface ScheduleSpecificDate<Value> {
|
|
366
447
|
readonly date: DateString;
|
|
367
|
-
readonly value:
|
|
448
|
+
readonly value: Value;
|
|
368
449
|
readonly name?: string;
|
|
369
450
|
}
|
|
370
451
|
/**
|
|
371
452
|
* 個別の日付の期間(両端を含む)の値。
|
|
372
453
|
* @public
|
|
373
454
|
*/
|
|
374
|
-
export interface
|
|
455
|
+
export interface ScheduleDateRange<Value> {
|
|
375
456
|
readonly from: DateString;
|
|
376
457
|
readonly to: DateString;
|
|
377
|
-
readonly value:
|
|
458
|
+
readonly value: Value;
|
|
378
459
|
readonly name?: string;
|
|
379
460
|
}
|
|
380
461
|
/**
|
|
@@ -383,70 +464,85 @@ export interface DateRangeValue<T> {
|
|
|
383
464
|
*/
|
|
384
465
|
export interface HolidaySourceOptions<Kind extends string = string> {
|
|
385
466
|
/** 祝日の提供元(例: jp)。複数渡すと和集合になる */
|
|
467
|
+
readonly holidayProvider?: HolidayProvider<Kind> | readonly HolidayProvider<Kind>[];
|
|
468
|
+
/** @deprecated 0.30.0 で holidayProvider に改名した。1.0.0 で削除する */
|
|
386
469
|
readonly holidays?: HolidayProvider<Kind> | readonly HolidayProvider<Kind>[];
|
|
470
|
+
/** @deprecated 0.30.0 で outOfRangePolicy に改名した。1.0.0 で削除する */
|
|
471
|
+
readonly outOfRange?: "throw" | "ignore";
|
|
472
|
+
/** @deprecated 0.30.0 で unconfirmedHolidayPolicy に改名した。1.0.0 で削除する */
|
|
473
|
+
readonly unconfirmedHolidays?: "accept" | "throw";
|
|
387
474
|
/**
|
|
388
475
|
* 日時の入力(Date・オフセット付き文字列など)を暦日に変換するタイムゾーン。
|
|
389
476
|
* 省略時は祝日の提供元のタイムゾーン、提供元もなければ "UTC"
|
|
390
477
|
*/
|
|
391
478
|
readonly timeZone?: string;
|
|
392
479
|
/** 祝日の提供元の対応年を外れた日付の扱い(既定: "throw") */
|
|
393
|
-
readonly
|
|
480
|
+
readonly outOfRangePolicy?: "throw" | "ignore";
|
|
394
481
|
/**
|
|
395
482
|
* 判定が未確定の祝日(提供元の confirmed: false。日本の春分の日・秋分の日の予測など)に触れたときの扱い(既定: "accept")。
|
|
396
|
-
* "throw" にすると、
|
|
483
|
+
* "throw" にすると、dayInfoOn・isBusinessDay に限らず、営業日の探索・調整・期日の計算の途中で評価した日や、祝日の翌日・祝前日の
|
|
397
484
|
* 規則が見る隣の日を含め、祝日を引いた日が未確定の祝日なら unconfirmed-holiday の RangeError を投げる。
|
|
398
485
|
* holidaysInYear・holidaysBetween は投げないので、影響する日の列挙に使える。
|
|
399
486
|
* 判定に祝日を使う設定(holidayPolicy が "ignore" でない、または祝日に従属する規則がある)でだけ意味がある
|
|
400
487
|
*/
|
|
401
|
-
readonly
|
|
488
|
+
readonly unconfirmedHolidayPolicy?: "accept" | "throw";
|
|
402
489
|
}
|
|
403
490
|
/**
|
|
404
491
|
* スケジュールの設定。
|
|
405
492
|
* @public
|
|
406
493
|
*/
|
|
407
|
-
export interface ScheduleOptions<
|
|
494
|
+
export interface ScheduleOptions<Value, Kind extends string = string> extends HolidaySourceOptions<Kind> {
|
|
408
495
|
/** 曜日ごとの値([日, 月, 火, 水, 木, 金, 土]) */
|
|
409
|
-
readonly
|
|
410
|
-
/** 祝日の値の決め方(既定: "
|
|
411
|
-
readonly
|
|
496
|
+
readonly weekdayValues: readonly [Value, Value, Value, Value, Value, Value, Value];
|
|
497
|
+
/** 祝日の値の決め方(既定: "ignore") */
|
|
498
|
+
readonly holidayPolicy?: ScheduleHolidayPolicy<Value>;
|
|
412
499
|
/** 繰り返しの規則(毎週・毎月の第 n 曜日・毎月の日)の値 */
|
|
413
|
-
readonly
|
|
500
|
+
readonly recurringRules?: readonly ScheduleRecurringRule<Value, Kind>[];
|
|
414
501
|
/** 毎年の月日の値 */
|
|
415
|
-
readonly
|
|
502
|
+
readonly annualDates?: readonly (ScheduleAnnualDate<Value> | ScheduleAnnualRange<Value>)[];
|
|
503
|
+
/** @deprecated 0.30.0 で holidayPolicy に改名した(値 "weekday" は "ignore")。1.0.0 で削除する */
|
|
504
|
+
readonly holiday?: ScheduleHolidayPolicy<Value> | "weekday";
|
|
505
|
+
/** @deprecated 0.30.0 で recurringRules に改名した。1.0.0 で削除する */
|
|
506
|
+
readonly recurring?: readonly ScheduleRecurringRule<Value, Kind>[];
|
|
507
|
+
/** @deprecated 0.30.0 で annualDates に改名した。1.0.0 で削除する */
|
|
508
|
+
readonly annual?: readonly (ScheduleAnnualDate<Value> | ScheduleAnnualRange<Value>)[];
|
|
416
509
|
/** 個別の日付の値 */
|
|
417
|
-
readonly dates?: readonly (
|
|
510
|
+
readonly dates?: readonly (ScheduleSpecificDate<Value> | ScheduleDateRange<Value>)[];
|
|
418
511
|
}
|
|
419
512
|
/**
|
|
420
513
|
* 値を決めた規則(既知の値)。
|
|
421
514
|
* @public
|
|
422
515
|
*/
|
|
423
|
-
export type
|
|
516
|
+
export type KnownScheduleDayReason = "date" | "annual" | "recurring" | "holiday" | "weekday";
|
|
424
517
|
/**
|
|
425
518
|
* 値を決めた規則。将来の版で値が増えることがあるので、分岐では「その他」も扱うこと。
|
|
426
|
-
* すべての値を網羅したことを型で確かめたい場合は
|
|
519
|
+
* すべての値を網羅したことを型で確かめたい場合は KnownScheduleDayReason を使う。
|
|
427
520
|
* @public
|
|
428
521
|
*/
|
|
429
|
-
export type
|
|
522
|
+
export type ScheduleDayReason = KnownScheduleDayReason | (string & {});
|
|
430
523
|
/**
|
|
431
524
|
* 1 日分の値と、その値を決めた規則。
|
|
432
525
|
* @public
|
|
433
526
|
*/
|
|
434
|
-
export interface
|
|
527
|
+
export interface ScheduleDayInfo<Value, Kind extends string = string> {
|
|
435
528
|
readonly date: DateString;
|
|
436
529
|
readonly weekday: Weekday;
|
|
437
|
-
readonly value:
|
|
530
|
+
readonly value: Value;
|
|
438
531
|
/** 値を決めた規則 */
|
|
439
|
-
readonly reason:
|
|
532
|
+
readonly reason: ScheduleDayReason;
|
|
440
533
|
/** 値を決めた規則の名前(dates・annual・recurring の name、祝日なら祝日名) */
|
|
441
534
|
readonly name?: string;
|
|
442
535
|
/** その日が祝日なら祝日(holiday の規則に関係なく付く) */
|
|
443
536
|
readonly holiday?: Holiday<Kind>;
|
|
444
|
-
/** 祝日から振り替えられた規則で値が決まった場合、振替の元の日付(
|
|
537
|
+
/** 祝日から振り替えられた規則で値が決まった場合、振替の元の日付(holidayOverlapPolicy: "after-holiday") */
|
|
445
538
|
readonly shiftedFrom?: DateString;
|
|
446
539
|
/**
|
|
447
|
-
* 値を決めた規則の設定の中の位置(規則の診断の path と同じ形。例: "
|
|
448
|
-
* dates・
|
|
540
|
+
* 値を決めた規則の設定の中の位置(規則の診断の path と同じ形。例: "recurringRules[0]")。
|
|
541
|
+
* dates・annualDates・recurringRules(振替先を含む)で決まった日にだけ付き、祝日・曜日で決まった日には付かない。
|
|
542
|
+
* 旧名のキーで書いた設定でも、新しい名前の位置で返す
|
|
449
543
|
*/
|
|
544
|
+
readonly optionPath?: string;
|
|
545
|
+
/** @deprecated 0.30.0 で optionPath に改名した(同じ値)。1.0.0 で削除する */
|
|
450
546
|
readonly rulePath?: string;
|
|
451
547
|
}
|
|
452
548
|
/**
|
|
@@ -458,9 +554,13 @@ export interface HolidayLookup<Kind extends string = string> {
|
|
|
458
554
|
readonly timeZone: string;
|
|
459
555
|
/** 祝日の提供元 */
|
|
460
556
|
readonly providers: readonly HolidayProvider<Kind>[];
|
|
461
|
-
/** 祝日の提供元の対応年を外れた日付の扱い(設定の
|
|
557
|
+
/** 祝日の提供元の対応年を外れた日付の扱い(設定の outOfRangePolicy) */
|
|
558
|
+
readonly outOfRangePolicy: "throw" | "ignore";
|
|
559
|
+
/** 未確定の祝日に触れたときの扱い(設定の unconfirmedHolidayPolicy) */
|
|
560
|
+
readonly unconfirmedHolidayPolicy: "accept" | "throw";
|
|
561
|
+
/** @deprecated 0.30.0 で outOfRangePolicy に改名した(同じ値)。1.0.0 で削除する */
|
|
462
562
|
readonly outOfRange: "throw" | "ignore";
|
|
463
|
-
/**
|
|
563
|
+
/** @deprecated 0.30.0 で unconfirmedHolidayPolicy に改名した(同じ値)。1.0.0 で削除する */
|
|
464
564
|
readonly unconfirmedHolidays: "accept" | "throw";
|
|
465
565
|
/** 入力をタイムゾーンでの暦日に変換する */
|
|
466
566
|
dateOf(input: DateInput): DateString;
|
|
@@ -477,6 +577,8 @@ export interface HolidayLookup<Kind extends string = string> {
|
|
|
477
577
|
/** 祝日か */
|
|
478
578
|
isHoliday(input: DateInput): boolean;
|
|
479
579
|
/** 祝日なら祝日を返す */
|
|
580
|
+
holidayOn(input: DateInput): Holiday<Kind> | undefined;
|
|
581
|
+
/** @deprecated 0.30.0 で holidayOn に改名した。1.0.0 で削除する */
|
|
480
582
|
getHoliday(input: DateInput): Holiday<Kind> | undefined;
|
|
481
583
|
/** その年の祝日 */
|
|
482
584
|
holidaysInYear(year: number): readonly Holiday<Kind>[];
|
|
@@ -487,28 +589,30 @@ export interface HolidayLookup<Kind extends string = string> {
|
|
|
487
589
|
* 日ごとに値を返すスケジュール。
|
|
488
590
|
* @public
|
|
489
591
|
*/
|
|
490
|
-
export interface Schedule<
|
|
592
|
+
export interface Schedule<Value, Kind extends string = string> extends HolidayLookup<Kind> {
|
|
491
593
|
/** その日の値 */
|
|
492
|
-
valueOn(input: DateInput):
|
|
594
|
+
valueOn(input: DateInput): Value;
|
|
493
595
|
/**
|
|
494
|
-
* その日の値と、値を決めた規則(reason)。reason
|
|
596
|
+
* その日の値と、値を決めた規則(reason)。reason は値を決めた規則なので、holidayPolicy が "ignore"(曜日どおり)の
|
|
495
597
|
* ときは、祝日でも "weekday" になる。祝日かどうかは holiday の有無で判定する
|
|
496
598
|
*/
|
|
497
|
-
|
|
599
|
+
dayInfoOn(input: DateInput): ScheduleDayInfo<Value, Kind>;
|
|
600
|
+
/** @deprecated 0.30.0 で dayInfoOn に改名した。1.0.0 で削除する */
|
|
601
|
+
dayInfo(input: DateInput): ScheduleDayInfo<Value, Kind>;
|
|
498
602
|
/** 期間内の日ごとの値と規則(両端を含む。from が to より後ならエラー) */
|
|
499
|
-
daysBetween(from: DateInput, to: DateInput): readonly
|
|
603
|
+
daysBetween(from: DateInput, to: DateInput): readonly ScheduleDayInfo<Value, Kind>[];
|
|
500
604
|
}
|
|
501
605
|
/** @internal "MM-DD" として正しいか(2 月 29 日は可) */
|
|
502
606
|
export declare function isValidMonthDay(value: unknown): value is string;
|
|
503
607
|
/** @internal 曜日の番号として正しいか */
|
|
504
608
|
export declare const isWeekday: (value: unknown) => value is Weekday;
|
|
505
609
|
/** @internal 個別の日付の規則(日数で表した期間) */
|
|
506
|
-
export interface DateRule<
|
|
610
|
+
export interface DateRule<Value> {
|
|
507
611
|
/** 設定の中の位置(例: "closedDates[1]") */
|
|
508
612
|
readonly path: string;
|
|
509
613
|
readonly from: number;
|
|
510
614
|
readonly to: number;
|
|
511
|
-
readonly value:
|
|
615
|
+
readonly value: Value;
|
|
512
616
|
readonly name: string | undefined;
|
|
513
617
|
}
|
|
514
618
|
/** @internal 有効期間(日数。省略した側は null) */
|
|
@@ -517,12 +621,12 @@ export interface CompiledPeriod {
|
|
|
517
621
|
readonly effectiveTo: number | null;
|
|
518
622
|
}
|
|
519
623
|
/** @internal 毎年の月日の規則 */
|
|
520
|
-
export interface AnnualRule<
|
|
521
|
-
/** 設定の中の位置(例: "
|
|
624
|
+
export interface AnnualRule<Value> extends CompiledPeriod {
|
|
625
|
+
/** 設定の中の位置(例: "closedAnnualDates[0]") */
|
|
522
626
|
readonly path: string;
|
|
523
627
|
readonly from: string;
|
|
524
628
|
readonly to: string;
|
|
525
|
-
readonly value:
|
|
629
|
+
readonly value: Value;
|
|
526
630
|
readonly name: string | undefined;
|
|
527
631
|
}
|
|
528
632
|
/** @internal 日数 n が有効期間の中か */
|
|
@@ -531,12 +635,12 @@ export declare const inPeriod: (rule: CompiledPeriod, n: number) => boolean;
|
|
|
531
635
|
* @internal 個別の日付の規則を検証して取り込む。
|
|
532
636
|
* entry は "YYYY-MM-DD"・{ date }・{ from, to } のいずれか。値は valueOf で決める
|
|
533
637
|
*/
|
|
534
|
-
export declare function compileDateRules<
|
|
638
|
+
export declare function compileDateRules<Value>(c: IssueCollector, path: string, entries: unknown, valueOf: (entry: Record<string, unknown>, path: string) => Value | undefined, allowString: boolean): DateRule<Value>[];
|
|
535
639
|
/** @internal 毎年の月日の規則を検証して取り込む(entry は "MM-DD"・{ date }・{ from, to }) */
|
|
536
|
-
export declare function compileAnnualRules<
|
|
640
|
+
export declare function compileAnnualRules<Value>(c: IssueCollector, path: string, entries: unknown, valueOf: (entry: Record<string, unknown>, path: string) => Value | undefined, allowString: boolean): AnnualRule<Value>[];
|
|
537
641
|
/** @internal 繰り返しの規則(検証済み) */
|
|
538
|
-
export interface RecurringRuleCompiled<
|
|
539
|
-
/** 設定の中の位置(例: "
|
|
642
|
+
export interface RecurringRuleCompiled<Value> extends CompiledPeriod {
|
|
643
|
+
/** 設定の中の位置(例: "closedRecurringRules[0]") */
|
|
540
644
|
readonly path: string;
|
|
541
645
|
/** 曜日の規則なら曜日、日の規則なら null */
|
|
542
646
|
readonly weekday: Weekday | null;
|
|
@@ -554,6 +658,8 @@ export interface RecurringRuleCompiled<T> extends CompiledPeriod {
|
|
|
554
658
|
readonly days: ReadonlySet<number> | null;
|
|
555
659
|
/** 第 n 営業日の集合(第 n 営業日の規則以外では null) */
|
|
556
660
|
readonly businessDays: ReadonlySet<number> | null;
|
|
661
|
+
/** 週の第 n 営業日の規則の週の始まりの曜日(月の第 n 営業日・ほかの規則では null) */
|
|
662
|
+
readonly weekStart: number | null;
|
|
557
663
|
/** 営業日を数える基準(スケジュールの第 n 営業日の規則の calendar から。null なら自分の設定の「繰り返しの規則を除いた判定」) */
|
|
558
664
|
readonly basis: BasisOfMonth | null;
|
|
559
665
|
/** basis の元のカレンダー(診断で同じ基準かを比べるため。basis が null なら null) */
|
|
@@ -574,8 +680,8 @@ export interface RecurringRuleCompiled<T> extends CompiledPeriod {
|
|
|
574
680
|
readonly weekdays: ReadonlySet<number> | null;
|
|
575
681
|
/** 月の集合(null はすべての月) */
|
|
576
682
|
readonly months: ReadonlySet<number> | null;
|
|
577
|
-
readonly
|
|
578
|
-
readonly value:
|
|
683
|
+
readonly holidayOverlapPolicy: HolidayOverlapPolicy;
|
|
684
|
+
readonly value: Value;
|
|
579
685
|
readonly name: string | undefined;
|
|
580
686
|
}
|
|
581
687
|
/**
|
|
@@ -586,7 +692,7 @@ export type BasisOfMonth = (year: number, month: number) => readonly number[];
|
|
|
586
692
|
/** @internal カレンダーの判定関数から、月ごとに結果をキャッシュする基準を作る */
|
|
587
693
|
export declare function basisFromPredicate(isOpen: (date: DateString) => boolean): BasisOfMonth;
|
|
588
694
|
/** @internal 繰り返しの規則を検証して取り込む */
|
|
589
|
-
export declare function compileRecurringRules<
|
|
695
|
+
export declare function compileRecurringRules<Value>(c: IssueCollector, path: string, entries: unknown, valueOf: (entry: Record<string, unknown>, path: string) => Value | undefined, keys: readonly string[], context: "calendar" | "schedule", writtenPath?: string, jp?: boolean): RecurringRuleCompiled<Value>[];
|
|
590
696
|
/** @internal その日の祝日を返す関数(祝日・祝日の翌日・祝前日の規則の判定に使う。提供元の対応年の外は祝日でないとみなすこと) */
|
|
591
697
|
export type HolidayOf = (date: DateString) => Holiday<string> | undefined;
|
|
592
698
|
/**
|
|
@@ -602,63 +708,115 @@ export declare function matchRecurring(rule: RecurringRuleCompiled<unknown>, dat
|
|
|
602
708
|
* @internal 第 n 営業日の規則が自分の設定を基準にする場合の基準を作る(繰り返しの規則をすべて除いた判定で営業日か)。
|
|
603
709
|
* 基準が要らない設定(第 n 営業日の規則がない、またはすべて calendar を持つ)では undefined
|
|
604
710
|
*/
|
|
605
|
-
export declare function createBasis<
|
|
711
|
+
export declare function createBasis<Value, Kind extends string>(compiled: CompiledSchedule<Value, Kind>, lookup: HolidayLookupInternal<Kind>): BasisOfMonth | undefined;
|
|
606
712
|
/** @internal 祝日の提供元とタイムゾーンの設定を検証した結果 */
|
|
607
713
|
export interface HolidaySource<Kind extends string> {
|
|
608
714
|
readonly providers: readonly HolidayProvider<Kind>[];
|
|
609
715
|
readonly timeZone: string;
|
|
610
|
-
readonly
|
|
611
|
-
readonly
|
|
716
|
+
readonly outOfRangePolicy: "throw" | "ignore";
|
|
717
|
+
readonly unconfirmedHolidayPolicy: "accept" | "throw";
|
|
612
718
|
}
|
|
719
|
+
/** @internal 日本の祝日の提供元(ID が "JP"。包んだものを含む)を使うか(0.30.0 で改名した kinds の "national" を読み替えるため) */
|
|
720
|
+
export declare function usesJp(source: HolidaySource<string>): boolean;
|
|
613
721
|
/** @internal 祝日の提供元とタイムゾーンの設定を検証する */
|
|
614
722
|
export declare function compileHolidaySource<Kind extends string>(c: IssueCollector, options: Record<string, unknown>): HolidaySource<Kind>;
|
|
615
723
|
/** @internal 祝日を調べる機能を作る(設定は検証済みであること) */
|
|
616
724
|
export declare function createHolidayLookup<Kind extends string>(source: HolidaySource<Kind>): HolidayLookup<Kind> & {
|
|
617
|
-
|
|
725
|
+
holidayOfDate(date: DateString): Holiday<Kind> | undefined;
|
|
618
726
|
};
|
|
619
727
|
/** @internal 検証済みのスケジュールの規則 */
|
|
620
|
-
export interface CompiledSchedule<
|
|
728
|
+
export interface CompiledSchedule<Value, Kind extends string> {
|
|
621
729
|
readonly source: HolidaySource<Kind>;
|
|
622
|
-
readonly weekly: readonly
|
|
623
|
-
readonly holiday:
|
|
624
|
-
readonly annual: readonly AnnualRule<
|
|
625
|
-
readonly dates: readonly DateRule<
|
|
626
|
-
readonly recurring: readonly RecurringRuleCompiled<
|
|
730
|
+
readonly weekly: readonly Value[];
|
|
731
|
+
readonly holiday: ScheduleHolidayPolicy<Value>;
|
|
732
|
+
readonly annual: readonly AnnualRule<Value>[];
|
|
733
|
+
readonly dates: readonly DateRule<Value>[];
|
|
734
|
+
readonly recurring: readonly RecurringRuleCompiled<Value>[];
|
|
627
735
|
}
|
|
628
736
|
/** @internal 繰り返しの規則の項目 */
|
|
629
737
|
/** @internal 有効期間の項目 */
|
|
630
738
|
export declare const PERIOD_KEYS: string[];
|
|
631
739
|
export declare const RECURRING_RULE_KEYS: string[];
|
|
632
740
|
/** @internal スケジュールの設定を検証して取り込む(誤りは c に集める) */
|
|
633
|
-
export declare function compileScheduleOptions<
|
|
741
|
+
export declare function compileScheduleOptions<Value, Kind extends string>(c: IssueCollector, options: unknown): CompiledSchedule<Value, Kind> | undefined;
|
|
634
742
|
/** @internal 毎年の月日の規則の形がその月日 "MM-DD" に当てはまるか(有効期間は考えない) */
|
|
635
743
|
export declare function matchMonthDay(rule: AnnualRule<unknown>, monthDay: string): boolean;
|
|
636
744
|
/** @internal 毎年の月日の規則がその日に当てはまるか(有効期間を含む) */
|
|
637
745
|
export declare function matchAnnual(rule: AnnualRule<unknown>, date: DateString): boolean;
|
|
638
746
|
/** @internal 値を決めた規則(祝日・曜日で決まった場合は null) */
|
|
639
|
-
export type DecidingRule<
|
|
747
|
+
export type DecidingRule<Value> = DateRule<Value> | AnnualRule<Value> | RecurringRuleCompiled<Value>;
|
|
640
748
|
/** @internal 1 日分の結果と、値を決めた規則 */
|
|
641
|
-
export interface Resolution<
|
|
642
|
-
readonly day:
|
|
643
|
-
readonly rule: DecidingRule<
|
|
749
|
+
export interface Resolution<Value, Kind extends string> {
|
|
750
|
+
readonly day: ScheduleDayInfo<Value, Kind>;
|
|
751
|
+
readonly rule: DecidingRule<Value> | null;
|
|
644
752
|
}
|
|
645
753
|
type HolidayLookupInternal<Kind extends string> = ReturnType<typeof createHolidayLookup<Kind>>;
|
|
646
754
|
/**
|
|
647
755
|
* @internal 検証済みの規則から、1 日分の値と値を決めた規則を返す関数を作る。
|
|
648
756
|
* 規則の診断では、規則を取り除いた版と結果を比べるために、祝日を調べる機能(lookup)を共有して作る
|
|
649
757
|
*/
|
|
650
|
-
export declare function createResolver<
|
|
758
|
+
export declare function createResolver<Value, Kind extends string>(compiled: CompiledSchedule<Value, Kind>, lookup: HolidayLookupInternal<Kind>): (date: DateString) => Resolution<Value, Kind>;
|
|
651
759
|
/** @internal 期間(両端を含む)の日ごとに fn を呼んだ結果。from が to より後ならエラー */
|
|
652
760
|
export declare function mapDays<R>(from: DateString, to: DateString, fn: (date: DateString) => R): readonly R[];
|
|
653
761
|
/** @internal スケジュールの内部の判定を取り出す(createSchedule が作ったものでなければ undefined) */
|
|
654
|
-
export declare function infoOfSchedule<
|
|
762
|
+
export declare function infoOfSchedule<Value, Kind extends string>(schedule: Schedule<Value, Kind>): ((date: DateString) => ScheduleDayInfo<Value, Kind>) | undefined;
|
|
655
763
|
/** @internal 検証済みの規則からスケジュールを作る */
|
|
656
|
-
export declare function buildSchedule<
|
|
764
|
+
export declare function buildSchedule<Value, Kind extends string>(compiled: CompiledSchedule<Value, Kind>): Schedule<Value, Kind>;
|
|
657
765
|
/**
|
|
658
766
|
* 曜日・祝日・特定日の規則から、日ごとに値を返すスケジュールを作る。
|
|
659
767
|
*
|
|
660
768
|
* 設定は作る時点で複製されるので、あとから元の配列やオブジェクトを書き換えても結果は変わらない
|
|
661
|
-
* (値
|
|
769
|
+
* (値 Value そのものは複製しない)。設定の誤りは code 付きの RangeError になる。
|
|
770
|
+
* @public
|
|
771
|
+
*/
|
|
772
|
+
export declare function createSchedule<Value, Kind extends string = string>(options: ScheduleOptions<Value, Kind>): Schedule<Value, Kind>;
|
|
773
|
+
/**
|
|
774
|
+
* @deprecated 0.30.0 で ScheduleHolidayPolicy に改名した。1.0.0 で削除する
|
|
775
|
+
* @public
|
|
776
|
+
*/
|
|
777
|
+
export type HolidayValueRule<Value> = ScheduleHolidayPolicy<Value> | "weekday";
|
|
778
|
+
/**
|
|
779
|
+
* @deprecated 0.30.0 で HolidayOverlapPolicy に改名した。1.0.0 で削除する
|
|
780
|
+
* @public
|
|
781
|
+
*/
|
|
782
|
+
export type OnHolidayRule = HolidayOverlapPolicy;
|
|
783
|
+
/**
|
|
784
|
+
* @deprecated 0.30.0 で ScheduleRecurringRule に改名した。1.0.0 で削除する
|
|
785
|
+
* @public
|
|
786
|
+
*/
|
|
787
|
+
export type RecurringValue<Value, Kind extends string = string> = ScheduleRecurringRule<Value, Kind>;
|
|
788
|
+
/**
|
|
789
|
+
* @deprecated 0.30.0 で ScheduleAnnualDate に改名した。1.0.0 で削除する
|
|
790
|
+
* @public
|
|
791
|
+
*/
|
|
792
|
+
export type AnnualValue<Value> = ScheduleAnnualDate<Value>;
|
|
793
|
+
/**
|
|
794
|
+
* @deprecated 0.30.0 で ScheduleAnnualRange に改名した。1.0.0 で削除する
|
|
795
|
+
* @public
|
|
796
|
+
*/
|
|
797
|
+
export type AnnualRangeValue<Value> = ScheduleAnnualRange<Value>;
|
|
798
|
+
/**
|
|
799
|
+
* @deprecated 0.30.0 で ScheduleSpecificDate に改名した。1.0.0 で削除する
|
|
800
|
+
* @public
|
|
801
|
+
*/
|
|
802
|
+
export type DateValue<Value> = ScheduleSpecificDate<Value>;
|
|
803
|
+
/**
|
|
804
|
+
* @deprecated 0.30.0 で ScheduleDateRange に改名した。1.0.0 で削除する
|
|
805
|
+
* @public
|
|
806
|
+
*/
|
|
807
|
+
export type DateRangeValue<Value> = ScheduleDateRange<Value>;
|
|
808
|
+
/**
|
|
809
|
+
* @deprecated 0.30.0 で ScheduleDayInfo に改名した。1.0.0 で削除する
|
|
810
|
+
* @public
|
|
811
|
+
*/
|
|
812
|
+
export type ScheduleDay<Value, Kind extends string = string> = ScheduleDayInfo<Value, Kind>;
|
|
813
|
+
/**
|
|
814
|
+
* @deprecated 0.30.0 で ScheduleDayReason に改名した。1.0.0 で削除する
|
|
815
|
+
* @public
|
|
816
|
+
*/
|
|
817
|
+
export type ScheduleReason = ScheduleDayReason;
|
|
818
|
+
/**
|
|
819
|
+
* @deprecated 0.30.0 で KnownScheduleDayReason に改名した。1.0.0 で削除する
|
|
662
820
|
* @public
|
|
663
821
|
*/
|
|
664
|
-
export
|
|
822
|
+
export type KnownScheduleReason = KnownScheduleDayReason;
|