Japan Public Holiday Generator

1.0.3 · active · verified Wed Apr 15

jpholiday is a pure-Python library designed to easily retrieve Japan's national holidays based on data published by the Cabinet Office. It is currently at version 1.0.3 and maintains an active release cadence with several updates in recent months, continuously improving accuracy and functionality.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to check if a specific date is a holiday, retrieve holiday names for a given date, and list all holidays for a particular year using the JPHoliday class.

import datetime
from jpholiday import JPHoliday

# Initialize the JPHoliday instance
jpholiday_instance = JPHoliday()

# Check if a specific date is a holiday
date_to_check = datetime.date(2024, 1, 1) # New Year's Day
is_holiday = jpholiday_instance.is_holiday(date_to_check)
print(f"Is {date_to_check} a holiday? {is_holiday}")

# Get the name(s) of holidays on a specific date
holidays_on_date = jpholiday_instance.holidays(date_to_check)
if holidays_on_date:
    for holiday in holidays_on_date:
        print(f"Holiday on {holiday.date}: {holiday.name}")

# Get all holidays for a specific year
year_to_check = 2024
year_holidays = jpholiday_instance.year_holidays(year_to_check)
print(f"\nHolidays in {year_to_check} (first 3):")
for holiday in year_holidays[:3]:
    print(f"  {holiday.date}: {holiday.name}")

view raw JSON →