Skip to content

Commit

Permalink
fix: Glasgow City Council
Browse files Browse the repository at this point in the history
fix: #1166
  • Loading branch information
m26dvd committed Jan 15, 2025
1 parent a9ddd6a commit f58c812
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions uk_bin_collection/uk_bin_collection/councils/GlasgowCityCouncil.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from bs4 import BeautifulSoup

from uk_bin_collection.uk_bin_collection.common import *
Expand Down Expand Up @@ -32,15 +34,24 @@ def parse_data(self, page: str, **kwargs) -> dict:
for p in ps:
collection = p.text.strip().replace("Your next ", "").split(".")[0]
bin_type = collection.split(" day is")[0]
collection_date = datetime.strptime(
remove_ordinal_indicator_from_date_string(collection).split("day is ")[
1
],
"%A %d %B %Y",
)
collection_date = remove_ordinal_indicator_from_date_string(
collection
).split("day is ")[1]
if collection_date == "Today":
collection_date = datetime.today().strftime(date_format)
elif collection_date == "Tomorrow":
collection_date = (datetime.today() + timedelta(days=1)).strftime(
date_format
)
print(collection_date)
else:
collection_date = datetime.strptime(
collection_date,
"%A %d %B %Y",
).strftime(date_format)
dict_data = {
"type": bin_type,
"collectionDate": collection_date.strftime(date_format),
"collectionDate": collection_date,
}
data["bins"].append(dict_data)

Expand Down

0 comments on commit f58c812

Please sign in to comment.