Created
February 7, 2024 21:26
-
-
Save 64board/0f9485c4140f62565e02ca941417f68f to your computer and use it in GitHub Desktop.
Holidays API example from https://dev.timeanddate.com/holidays/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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