From dee89ecc858eafafab69be81dfbaf46210c301bc Mon Sep 17 00:00:00 2001 From: Dean Longstaff Date: Fri, 3 Nov 2023 09:15:31 +0000 Subject: [PATCH] Fix "Date not available" error. Fixed an issue where the date returned from stockton_gov_uk would be "Date not available" during winter months for garden waste. This would cause an error when converting it to a date string. --- .../waste_collection_schedule/source/stockton_gov_uk.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stockton_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stockton_gov_uk.py index caf7978e9..b0b490e1f 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stockton_gov_uk.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stockton_gov_uk.py @@ -108,6 +108,10 @@ def fetch(self): ] for date_node in date_nodes: + # If date is "Date not available" then skip (Winter period) + if date_node.text.strip() == "Date not available": + continue + # Remove ordinal suffixes from date string date_string = re.sub( r"(?<=[0-9])(?:st|nd|rd|th)", "", date_node.text.strip()