Skip to content

Commit

Permalink
fix: correct date/year logic for West Lindsey District Council
Browse files Browse the repository at this point in the history
  • Loading branch information
dp247 committed Dec 17, 2024
1 parent 2f3c18d commit 1e5e7fe
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ def parse_data(self, page: str, **kwargs) -> dict:
for bin_date in bin_dates:
# Split the bin date into day and month and build a full date with the current year
split_date = bin_date.split("/")
if len(split_date[0]) < 1:
raise ValueError("Error parsing dates retrieved from website")
full_date = datetime(
datetime.now().year, int(split_date[1]), int(split_date[0])
)

# If the current month is December and one of the next collections is in January, increment the year
if datetime.now().month == 12 and int(split_date[1]) == 1:
full_date = bin_date + relativedelta(years=1)
if datetime.now().month == 12 and int(split_date[1]) < 12:
full_date = datetime(year=datetime.now().year + 1, month=int(split_date[1]), day=int(split_date[0]))

# Since data in unordered, add to a tuple
collections.append((bin_type.title(), full_date))
Expand Down

0 comments on commit 1e5e7fe

Please sign in to comment.