python-holidays icon indicating copy to clipboard operation
python-holidays copied to clipboard

Canadian Holidays are not working in 2022

Open Dpananos opened this issue 2 years ago • 3 comments

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'

Dpananos avatar Sep 08 '22 18:09 Dpananos

I'll look into this.

kasya avatar Sep 09 '22 03:09 kasya

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!

dr-prodigy avatar Sep 14 '22 12:09 dr-prodigy

Here's a fix: https://github.com/dr-prodigy/python-holidays/pull/715

bkthomps avatar Sep 16 '22 05:09 bkthomps

This is to be closed.. thx!

dr-prodigy avatar Dec 16 '22 08:12 dr-prodigy