@@ -178,7 +178,7 @@ public struct CalculateCalendarLogic {
178
178
minute: 0 ,
179
179
second: 0 ,
180
180
nanosecond: 0 ) ) else {
181
- fatalError ( ) // FIXME: throwにしたほうがよい?
181
+ fatalError ( " date is invalid. " )
182
182
}
183
183
let weekdayNum = cal. component ( . weekday, from: date) // 1:日曜日 ~ 7:土曜日
184
184
@@ -200,6 +200,12 @@ public struct CalculateCalendarLogic {
200
200
/// See also: http://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html
201
201
let SpecialProvisionYear = 2020
202
202
203
+ /// 「国民の祝日」の特例が2020年(平成32年12月2日)に公布・施行された。
204
+ /// 令和3年(2021年)に限り「海の日」は7月22日、「スポーツの日」は7月23日、「山の日」は8月8日となる。
205
+ /// ※ 国民の祝日に関する法律第3条第2項の規定に基づき、8月9日は休日となります。
206
+ /// See also: http://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html
207
+ let SpecialExtraProvisionYear = 2021
208
+
203
209
/// (注意)春分の日・秋分の日は1948年以前も祝祭日であったが、このカレンダーロジックの基準は1948年〜を基準とするので考慮しない
204
210
/// See also: https://ja.wikipedia.org/wiki/%E7%9A%87%E9%9C%8A%E7%A5%AD
205
211
@@ -306,29 +312,38 @@ public struct CalculateCalendarLogic {
306
312
case ( year, 5 , 6 , _) where year >= AlternateHolidaysLawYear && getGoldenWeekAlterHoliday ( year: year, weekday: weekday) :
307
313
return true
308
314
309
- //(1).7月20日(1996年から2002年まで)、(2).7月の第3月曜日(2003年から)、(3).7月23日(2020年のみ): 海の日
315
+ //(1).7月20日(1996年から2002年まで)、(2).7月の第3月曜日(2003年から)、(3).7月23日(2020年のみ)、(4).7月22日(2021年のみ) : 海の日
310
316
case ( 1996 ... 2002 , 7 , 20 , _) :
311
317
return true
312
318
313
319
case ( year, 7 , 15 ... 21 , . mon)
314
- where 2003 <= year && year != SpecialProvisionYear:
320
+ where 2003 <= year && year != SpecialProvisionYear && year != SpecialExtraProvisionYear :
315
321
return true
316
322
317
323
case ( SpecialProvisionYear, 7 , 23 , _) :
318
324
return true
319
-
325
+
326
+ case ( SpecialExtraProvisionYear, 7 , 22 , _) :
327
+ return true
328
+
320
329
//7月21日: 海の日の振替休日
321
330
case ( 1996 ... 2002 , 7 , 21 , . mon) :
322
331
return true
323
332
324
- //(1).8月11日(2016年から)、(2).8月10日(2020年のみ): 山の日
333
+ //(1).8月11日(2016年から)、(2).8月10日(2020年のみ)、(3).8月8日(2021年のみ ※8月9日振替休日) : 山の日
325
334
case ( year, 8 , 11 , _)
326
- where year > 2015 && year != SpecialProvisionYear:
335
+ where year > 2015 && year != SpecialProvisionYear && year != SpecialExtraProvisionYear :
327
336
return true
328
337
329
338
case ( SpecialProvisionYear, 8 , 10 , _) :
330
339
return true
331
340
341
+ case ( SpecialExtraProvisionYear, 8 , 8 , _) :
342
+ return true
343
+
344
+ case ( SpecialExtraProvisionYear, 8 , 9 , . mon) :
345
+ return true
346
+
332
347
//8月12日: 山の日の振替休日
333
348
case ( year, 8 , 12 , . mon) where year > 2015 :
334
349
return true
@@ -364,17 +379,20 @@ public struct CalculateCalendarLogic {
364
379
&& getAlterHolidaySliverWeek ( year: year) && year > 2008 :
365
380
return true
366
381
367
- //(1).10月10日(1966年から1999年まで)、(2).10月の第2月曜日(2000年から)、(3).7月24日(2020年のみ): 体育の日(スポーツの日)
382
+ //(1).10月10日(1966年から1999年まで)、(2).10月の第2月曜日(2000年から)、(3).7月24日(2020年のみ)、(4).7月23日(2021年のみ) : 体育の日(スポーツの日)
368
383
case ( 1966 ... 1999 , 10 , 10 , _) :
369
384
return true
370
385
371
386
case ( year, 10 , 8 ... 14 , . mon)
372
- where year > 1999 && year != SpecialProvisionYear:
387
+ where year > 1999 && year != SpecialProvisionYear && year != SpecialExtraProvisionYear :
373
388
return true
374
389
375
390
case ( SpecialProvisionYear, 7 , 24 , _) :
376
391
return true
377
-
392
+
393
+ case ( SpecialExtraProvisionYear, 7 , 23 , _) :
394
+ return true
395
+
378
396
//10月11日: 体育の日の振替休日
379
397
case ( 1966 ... 1999 , 10 , 11 , . mon) :
380
398
return true
0 commit comments