python-holidays
python-holidays copied to clipboard
Canadian Holidays are not working in 2022
The folllowling should return "Christmas Day" but does not
import holidays
holidays.CA().get('2022-12-25')
# No return
However, it does work for the US
holidays.US().get('2022-12-25')
'Christmas Day'
I'll look into this.
Hi @Dpananos I made a check, and I confirm Canada code is working as expected: the difference between it and the other countries is it applies observance by default:
>>> import holidays
>>> h = holidays.CA()
>>> h
holidays.country_holidays('CA', subdiv='ON')
>>> h.get('2022-12-25')
>>> h
{datetime.date(2022, 1, 1): "New Year's Day", datetime.date(2022, 2, 21): 'Family Day', datetime.date(2022, 4, 15): 'Good Friday', datetime.date(2022, 4, 18): 'Easter Monday', datetime.date(2022, 5, 23): 'Victoria Day', datetime.date(2022, 7, 1): 'Canada Day', datetime.date(2022, 8, 1): 'Civic Holiday', datetime.date(2022, 9, 5): 'Labour Day', datetime.date(2022, 10, 10): 'Thanksgiving', datetime.date(2022, 12, 27): 'Christmas Day (Observed)', datetime.date(2022, 12, 26): 'Boxing Day'}
>>> h.get('2022-12-27')
'Christmas Day (Observed)'
Basically, Christmas Day is there, but for 2022, is shifted to 2022-12-27.
In the end, this behaviour could be debated (could you please check whether it's correct or not?), but there seems not to be any technical issue behind it (ie: it's like so by design).
Please let me know if this makes sense to you, thank you!
Here's a fix: https://github.com/dr-prodigy/python-holidays/pull/715
This is to be closed.. thx!