Skip to content

Commit

Permalink
fix: Holidays subdivision error
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverCullimore committed Nov 1, 2023
1 parent 900519d commit 2fc1e56
Showing 1 changed file with 7 additions and 13 deletions.
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

0 comments on commit 2fc1e56

Please sign in to comment.