Workalendar

17.0.0 · active · verified Sat Apr 11

Workalendar is a Python library providing a comprehensive toolkit for calculating holidays and working days across various countries and regions worldwide. It's currently at version 17.0.0 and sees regular releases, often driven by updates to national holidays and the addition of new calendars.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate a country-specific calendar, retrieve a list of holidays for a particular year, and check whether a given date is considered a working day.

from datetime import date
from workalendar.europe import France

# Initialize a calendar for a specific country
cal = France()

year = 2024

# Get all holidays for a given year
holidays_2024 = cal.holidays(year)
print(f"Holidays in France for {year}:")
for hol_date, hol_name in holidays_2024:
    print(f"  {hol_date}: {hol_name}")

# Check if a specific day is a working day
test_date_christmas = date(2024, 12, 25) # Christmas Day
test_date_weekday = date(2024, 1, 10) # A Wednesday

print(f"\nIs {test_date_christmas} a working day in France? {cal.is_working_day(test_date_christmas)}")
print(f"Is {test_date_weekday} a working day in France? {cal.is_working_day(test_date_weekday)}")

view raw JSON →