from datetime import date
from datetime import datetime
import holidays
us_holidays = holidays.country_holidays('US')
# string
us_holidays.get('2014-01-01')
us_holidays['2014-01-01']
# date
us_holidays[date(2015, 1, 1)]
# datetime
us_holidays[datetime.fromisoformat('2011-01-01T00:05:23')]
"New Year's Day"
holidays.JP(years=2020)
{datetime.date(2020, 1, 1): '元日', datetime.date(2020, 1, 13): '成人の日', datetime.date(2020, 2, 11): '建国記念の日', datetime.date(2020, 2, 23): '天皇誕生日', datetime.date(2020, 3, 20): '春分の日', datetime.date(2020, 4, 29): '昭和の日', datetime.date(2020, 5, 3): '憲法記念日', datetime.date(2020, 5, 4): 'みどりの日', datetime.date(2020, 5, 5): 'こどもの日', datetime.date(2020, 7, 23): '海の日', datetime.date(2020, 8, 10): '山の日', datetime.date(2020, 9, 21): '敬老の日', datetime.date(2020, 9, 22): '秋分の日', datetime.date(2020, 7, 24): 'スポーツの日', datetime.date(2020, 11, 3): '文化の日', datetime.date(2020, 11, 23): '勤労感謝の日', datetime.date(2020, 2, 24): '振替休日', datetime.date(2020, 5, 6): '振替休日'}
holidays.US(years = [2020, 2021])
{datetime.date(2020, 1, 1): "New Year's Day", datetime.date(2020, 1, 20): 'Martin Luther King Jr. Day', datetime.date(2020, 2, 17): "Washington's Birthday", datetime.date(2020, 5, 25): 'Memorial Day', datetime.date(2020, 7, 4): 'Independence Day', datetime.date(2020, 7, 3): 'Independence Day (Observed)', datetime.date(2020, 9, 7): 'Labor Day', datetime.date(2020, 10, 12): 'Columbus Day', datetime.date(2020, 11, 11): 'Veterans Day', datetime.date(2020, 11, 26): 'Thanksgiving', datetime.date(2020, 12, 25): 'Christmas Day', datetime.date(2021, 1, 1): "New Year's Day", datetime.date(2021, 12, 31): "New Year's Day (Observed)", datetime.date(2021, 1, 18): 'Martin Luther King Jr. Day', datetime.date(2021, 2, 15): "Washington's Birthday", datetime.date(2021, 5, 31): 'Memorial Day', datetime.date(2021, 6, 19): 'Juneteenth National Independence Day', datetime.date(2021, 6, 18): 'Juneteenth National Independence Day (Observed)', datetime.date(2021, 7, 4): 'Independence Day', datetime.date(2021, 7, 5): 'Independence Day (Observed)', datetime.date(2021, 9, 6): 'Labor Day', datetime.date(2021, 10, 11): 'Columbus Day', datetime.date(2021, 11, 11): 'Veterans Day', datetime.date(2021, 11, 25): 'Thanksgiving', datetime.date(2021, 12, 25): 'Christmas Day', datetime.date(2021, 12, 24): 'Christmas Day (Observed)'}
holidays.country_holidays('US', subdiv='CA', years=2000)
{datetime.date(2000, 1, 1): "New Year's Day", datetime.date(2000, 1, 17): 'Martin Luther King Jr. Day', datetime.date(2000, 2, 12): "Lincoln's Birthday", datetime.date(2000, 2, 11): "Lincoln's Birthday (Observed)", datetime.date(2000, 2, 21): "Washington's Birthday", datetime.date(2000, 3, 31): 'César Chávez Day', datetime.date(2000, 5, 29): 'Memorial Day', datetime.date(2000, 7, 4): 'Independence Day', datetime.date(2000, 9, 4): 'Labor Day', datetime.date(2000, 10, 9): 'Columbus Day', datetime.date(2000, 11, 11): 'Veterans Day', datetime.date(2000, 11, 10): 'Veterans Day (Observed)', datetime.date(2000, 11, 23): 'Thanksgiving', datetime.date(2000, 11, 24): 'Day After Thanksgiving', datetime.date(2000, 12, 25): 'Christmas Day'}
us_holidays = holidays.country_holidays('US')
us_holidays['2014-01-01': '2014-06-01']
[datetime.date(2014, 1, 1), datetime.date(2014, 1, 20), datetime.date(2014, 2, 17), datetime.date(2014, 5, 26)]
# string
'2014-01-01' in us_holidays
# date
date(2015, 1, 1) in us_holidays
# datetime
datetime.fromisoformat('2011-01-01T00:05:23') in us_holidays
True
holidays.country_holidays('US', years=2020) + holidays.country_holidays('CA') + holidays.country_holidays('MX')
{datetime.date(2020, 1, 1): "Año Nuevo [New Year's Day]", datetime.date(2020, 2, 3): 'Día de la Constitución [Constitution Day] (Observed)', datetime.date(2020, 2, 5): 'Día de la Constitución [Constitution Day]', datetime.date(2020, 3, 16): "Natalicio de Benito Juárez [Benito Juárez's birthday] (Observed)", datetime.date(2020, 3, 21): "Natalicio de Benito Juárez [Benito Juárez's birthday]", datetime.date(2020, 5, 1): 'Día del Trabajo [Labour Day]', datetime.date(2020, 9, 16): 'Día de la Independencia [Independence Day]', datetime.date(2020, 11, 16): 'Día de la Revolución [Revolution Day] (Observed)', datetime.date(2020, 11, 20): 'Día de la Revolución [Revolution Day]', datetime.date(2020, 12, 25): 'Christmas Day, Navidad [Christmas]', datetime.date(2020, 2, 17): "Washington's Birthday, Family Day", datetime.date(2020, 4, 10): 'Good Friday', datetime.date(2020, 4, 13): 'Easter Monday', datetime.date(2020, 5, 18): 'Victoria Day', datetime.date(2020, 7, 1): 'Canada Day', datetime.date(2020, 8, 3): 'Civic Holiday', datetime.date(2020, 9, 7): 'Labor Day, Labour Day', datetime.date(2020, 10, 12): 'Columbus Day, Thanksgiving', datetime.date(2020, 12, 28): 'Boxing Day (Observed)', datetime.date(2020, 1, 20): 'Martin Luther King Jr. Day', datetime.date(2020, 5, 25): 'Memorial Day', datetime.date(2020, 7, 4): 'Independence Day', datetime.date(2020, 7, 3): 'Independence Day (Observed)', datetime.date(2020, 11, 11): 'Veterans Day', datetime.date(2020, 11, 26): 'Thanksgiving'}