1. import datetime
  2. import jpholiday as jph
  3. #独自の日程を追加
  4. class TestHoliday1(jph.OriginalHoliday):
  5.     def _is_holiday(self, date):
  6.         if date == datetime.date(2023, 11, 23):
  7.             return True
  8.         return False
  9.     def _is_holiday_name(self, date):
  10.         return '振替休日'
  11. class TestHoliday2(jph.OriginalHoliday):
  12.     def _is_holiday(self, date):
  13.         if date == datetime.date(2024, 1, 12):
  14.             return True
  15.         return False
  16.     def _is_holiday_name(self, date):
  17.         return '大学休校※予定'
  18.     #長期休暇の開始と終了の日にちを指定
  19. class longtimeholiday1(jph.OriginalHoliday):
  20.     def _is_holiday(self, date):
  21.         if date.year == 2023 and date.month == 12 and date.day == 23:
  22.             return True
  23.         if date.year == 2024 and date.month == 1 and date.day == 5:
  24.             return True
  25.         return False
  26.     def _is_holiday_name(self, date):
  27.         return "冬休み開始or終了"
  28. class longtimeholiday2(jph.OriginalHoliday):
  29.     def _is_holiday(self, date):
  30.         if date.year == 2024 and date.month == 1 and date.day == 28:
  31.             return True
  32.         if date.year == 2024 and date.month == 4 and date.day == 6:
  33.             return True
  34.         return False
  35.     def _is_holiday_name(self, date):
  36.         return "春休み期間開始or終了"
  37. class lomgtime3(jph.OriginalHoliday):
  38.     def _is_holiday(self, date):
  39.         if date.year == 2024 and date.month == 1 and date.day == 22:
  40.             return True
  41.         if date.year == 2024 and date.month == 1 and date.day == 27:
  42.             return True
  43.         return False
  44.     def _is_holiday_name(self, date):
  45.         return "テスト期間開始or終了"
  46. #指定する範囲
  47. from_day = datetime.date(2023, 1, 1)
  48. to_day = datetime.date(2024, 4, 1)
  49. result = jph.between(from_day, to_day)
  50. print(f' {from_day.strftime("%Y/%m/%d")}{to_day.strftime("%Y/%m/%d")}:{result}')