Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Holidays subdivision error #413

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions uk_bin_collection/uk_bin_collection/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@


class Region(Enum):
UK = 1
ENG = 2
NIR = 3
SCT = 4
WLS = 5
ENG = 1
NIR = 2
SCT = 3
WLS = 4


def check_postcode(postcode: str):
Expand Down Expand Up @@ -134,19 +133,14 @@ def parse_header(raw_header: str) -> dict:
return header


def is_holiday(date_to_check: datetime, region: Region = Region.UK) -> bool:
def is_holiday(date_to_check: datetime, region: Region = Region.ENG) -> bool:
"""
Checks if a given date is a public holiday
:param date_to_check: Date to check if holiday
:param region: The UK nation to check. Defaults to UK.
:param region: The UK nation to check. Defaults to ENG.
:return: Bool - true if a holiday, false if not
"""
if region.name != "UK":
subdiv = region.name.capitalize()
else:
subdiv = region.name

uk_holidays = holidays.country_holidays("GB", subdiv=subdiv)
uk_holidays = holidays.country_holidays("GB", subdiv=region.name)

if date_to_check in uk_holidays:
return True
Expand Down
Loading