Skip to content

Commit 70d1ce7

Browse files
committed
Update regex; the string literal 'today' is also possible
1 parent c2dbfd8 commit 70d1ce7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

uk_bin_collection/uk_bin_collection/councils/FarehamBoroughCouncil.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ def parse_data(self, page: str, **kwargs) -> dict:
3838
if "rows" in bin_data:
3939
collection_str = bin_data["rows"][0]["DomesticBinDay"]
4040

41-
results = re.findall(r"(\d\d?\/\d\d?\/\d{4}) \((\w*)\)", collection_str)
41+
results = re.findall(r'(\d{1,2}/\d{1,2}/\d{4}|today)\s*\(([^)]+)\)', collection_str)
4242

4343
if results:
4444
for result in results:
45-
collection_date = datetime.strptime(result[0], "%d/%m/%Y")
45+
if (result[0] == "today"):
46+
collection_date = datetime.today()
47+
else:
48+
collection_date = datetime.strptime(result[0], "%d/%m/%Y")
4649
dict_data = {
4750
"type": result[1],
4851
"collectionDate": collection_date.strftime(date_format),

0 commit comments

Comments
 (0)