From 0bef67827deccb2b7ae7084b6f618682b6f2e93e Mon Sep 17 00:00:00 2001 From: Teofanis Papadopulos Date: Fri, 3 Jan 2025 13:24:08 +0000 Subject: [PATCH] fix: correctly handle year increment for January dates --- .../uk_bin_collection/councils/BroxbourneCouncil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py b/uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py index a2e8c61704..5d1c3070a2 100644 --- a/uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py +++ b/uk_bin_collection/uk_bin_collection/councils/BroxbourneCouncil.py @@ -43,6 +43,7 @@ def parse_data(self, page: str, **kwargs) -> dict: rows = table.find_all("tr") current_year = datetime.now().year + current_month = datetime.now().month # Process each row into a list of dictionaries for row in rows[1:]: # Skip the header row @@ -56,7 +57,7 @@ def parse_data(self, page: str, **kwargs) -> dict: if collection_date_text: try: collection_date = datetime.strptime(collection_date_text, "%a %d %b") - if collection_date.month == 1: + if collection_date.month == 1 and current_month != 1: collection_date = collection_date.replace(year=current_year + 1) else: collection_date = collection_date.replace(year=current_year)