Skip to content

Instantly share code, notes, and snippets.

@Bas-Man
Last active May 8, 2025 06:35
Show Gist options
  • Save Bas-Man/c9edc70ff61ef28525173bf69559f76a to your computer and use it in GitHub Desktop.
Save Bas-Man/c9edc70ff61ef28525173bf69559f76a to your computer and use it in GitHub Desktop.
Create a custom CorporateHolidays Object using the holidays Python package
NATIONAL_HOLIDAYS = [
"成人の日", "建国記念の日", "天皇誕生日", "春分の日", "昭和の日", "憲法記念日",
"みどりの日", "こどもの日", "海の日", "山の日", "敬老の日", "秋分の日",
"スポーツの日", "文化の日", "勤労感謝の日",
]
class CorporateHolidays(JPN):
"""
Customised Corporate Holidays and National Holidays for a Company in Japan
"""
def _populate(self, year: int) -> None:
"""
Remove National holidays that fall on Sunday. Add Additional Company holidays.
:param year:
"""
super()._populate(year)
self._add_holiday_dec_25("Closed")
self._add_holiday_dec_30("Closed")
self._add_holiday_dec_31("Closed")
self._add_holiday_jan_2("Closed")
self._add_holiday_jan_3("Closed")
hols = holidays.country_holidays(country="JPN", years=year)
for n_h in NATIONAL_HOLIDAYS:
p_dt = pendulum.instance(hols.get_named(n_h)[0])
if p_dt.day_of_week == 6:
self.pop_named(n_h)
del hols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment