Skip to content

Commit

Permalink
fix: parse datetimes correctly and round to midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
dp247 committed Apr 9, 2024
1 parent 410581f commit ee2bed5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions uk_bin_collection/uk_bin_collection/councils/BCPCouncil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
from datetime import timedelta

import requests
from bs4 import BeautifulSoup
Expand All @@ -15,6 +16,7 @@ class CouncilClass(AbstractGetBinDataClass):
"""

def parse_data(self, page: str, **kwargs) -> dict:

user_uprn = kwargs.get("uprn")
check_uprn(user_uprn)

Expand All @@ -28,8 +30,8 @@ def parse_data(self, page: str, **kwargs) -> dict:

for bin in json_data:
bin_type = bin["BinType"]
next_date = datetime.strptime(bin["Next"], "%m/%d/%Y %H:%M:%S %p")
subseq_date = datetime.strptime(bin["Subsequent"], "%m/%d/%Y %H:%M:%S %p")
next_date = datetime.strptime(bin["Next"], "%m/%d/%Y %I:%M:%S %p") + timedelta(hours=1)
subseq_date = datetime.strptime(bin["Subsequent"], "%m/%d/%Y %I:%M:%S %p") + timedelta(hours=1)
collections.append((bin_type, next_date))
collections.append((bin_type, subseq_date))

Expand Down

0 comments on commit ee2bed5

Please sign in to comment.