Check if some date is workday or holiday in China. Support 2004 ~ 2020. Available in Python2 and Python3.
pip install chinesecalendar
import datetime
# Check if 2018-04-30 is holiday in China
from chinese_calendar import is_workday, is_holiday
april_last = datetime.date(2018, 4, 30)
self.assertFalse(is_workday(april_last))
self.assertTrue(is_holiday(april_last))
# or check and get the holiday name
import chinese_calendar as calendar # with different import style
on_holiday, holiday_name = calendar.get_holiday_detail(april_last)
self.assertTrue(on_holiday)
self.assertEqual(calendar.Holiday.labour_day.value, holiday_name)
# even check if a holiday is in lieu
import chinese_calendar
self.assertFalse(chinese_calendar.is_in_lieu(datetime.date(2006, 1, 1)))
self.assertTrue(chinese_calendar.is_in_lieu(datetime.date(2006, 1, 2)))
If you fail to use Python directly, you can translate the constants file to get the complete chinese holiday arrangement.
- Fork & Clone this project
- Modify calendar definition file
- Run script to generate the constants file
- Create a PR