Skip to content

Instantly share code, notes, and snippets.

@64board
Created February 7, 2024 21:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 64board/0f9485c4140f62565e02ca941417f68f to your computer and use it in GitHub Desktop.
Save 64board/0f9485c4140f62565e02ca941417f68f to your computer and use it in GitHub Desktop.
Holidays API example from https://dev.timeanddate.com/holidays/
#!/usr/bin/env python3
"""
Holidays API from https://dev.timeanddate.com/holidays/
"""
from libtad import HolidaysService
from libtad.datatypes.holidays import HolidayType
access_key = 'ACCESS_KEY'
secret_key = 'SECRET_KEY'
country = "us"
service = HolidaysService(access_key, secret_key)
service.types = HolidayType.Federal | HolidayType.Weekdays
result = service.holidays_for_country(country, 2024)
for holiday in result:
holiday_name = holiday.name['en']
holiday_date = holiday.date.iso
print(f'{holiday_date} {holiday_name}')
##END##
@64board
Copy link
Author

64board commented Feb 7, 2024

Output:

2024-01-01 New Year's Day
2024-01-15 Martin Luther King Jr. Day
2024-02-19 Presidents' Day
2024-05-27 Memorial Day
2024-06-19 Juneteenth
2024-07-04 Independence Day
2024-09-02 Labor Day
2024-10-14 Columbus Day
2024-11-11 Veterans Day
2024-11-28 Thanksgiving Day
2024-12-25 Christmas Day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment