mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Update fenland_gov_uk
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from waste_collection_schedule import Collection
|
from waste_collection_schedule import Collection
|
||||||
@@ -68,11 +68,16 @@ class Source:
|
|||||||
collections = r.json()["features"][0]["properties"]["upcoming"]
|
collections = r.json()["features"][0]["properties"]["upcoming"]
|
||||||
for collectionDate in collections:
|
for collectionDate in collections:
|
||||||
for collection in collectionDate["collections"]:
|
for collection in collectionDate["collections"]:
|
||||||
|
collectionDate = datetime.strptime(
|
||||||
|
collectionDate["date"], "%Y-%m-%dT%H:%M:%SZ"
|
||||||
|
)
|
||||||
|
if collectionDate.hour == 23:
|
||||||
|
collectionDate = (timedelta(days=1) + collectionDate).date()
|
||||||
|
else:
|
||||||
|
collectionDate = collectionDate.date()
|
||||||
entries.append(
|
entries.append(
|
||||||
Collection(
|
Collection(
|
||||||
date=datetime.strptime(
|
date=collectionDate,
|
||||||
collectionDate["date"], "%Y-%m-%dT%H:%M:%SZ"
|
|
||||||
).date(),
|
|
||||||
t=collection["desc"],
|
t=collection["desc"],
|
||||||
icon=ICON_MAP.get(collection["name"]),
|
icon=ICON_MAP.get(collection["name"]),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user