I am currently working on a newish personal project. My plan is to create a Python version of a Google Script
app
that I am running. I wanted to find a way to determine if a given date is a national holiday. This requires taking into account that National Holidays that fall on a Sunday are moved to the following Monday or to
Tuesday if Monday is already a National Holiday. I also needed to support adding Company holidays. This is important as
it impacts some calculations. Enter the Python package: holidays
The Challenge
I needed to find a way that would allow me to check if a given date was a national holiday in Japan, and also provide support for addtional corporate holidays.
In Japan, Christmas is not a national holiday, but the company I work for sets Christmas as a company holiday. Addtionally, the 30th and 31st of December are generally given has holidays. As are January 2nd and 3rd with January 1st being an offical holiday.
I did my research and found holidays
and thought great. Let’s see what we can do.
Findings
The package ‘holiday’ provides lots of nice features and accurately returns dates as holidays.
Let’s take the recent Golden Week
. For 2025, みどりの日, (Greenery Day) falls on Sunday May 4th. With みどりの日 being moved to the 7th since it falls on a Sunday and Monday the 6th being 子どもの日, Children’s Day. This all seems fine. But I have a slight issue. I need Sunday to be returned as a non national holiday. As that day is not observed as a national holiday but is a normal weekend day.
After some scratching, google searching and finally looking the the GitHub repo of holidays
. I came across some documentation for creating a customised holiday object.
The Solution that works for me
This is the basic solution that I came up.
It follows the basic example in the packages own documentation. Line 17 pulls in the corporate holidays Lines 18 to 22 add the additional holidays that I require Line 23 pulls in the National Holidays for Japan Lines 24 to 27 then remove any National Holiday that falls on a Sunday
Conclusion
This worked out really well. So if you need to do something that requires custom national and corporate holidays. I suggest you give this package a spin.