Skip to content

Commit

Permalink
fix date sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram van Dartel authored and github-actions[bot] committed Feb 23, 2022
1 parent f293b59 commit 3a2e4c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
5 changes: 1 addition & 4 deletions custom_components/afvalwijzer/collector/opzet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ..common.day_sensor_data import DaySensorData
from ..common.next_sensor_data import NextSensorData
from ..const.const import _LOGGER, SENSOR_COLLECTOR_TO_URL, SENSOR_COLLECTORS_OPZET
from ..const.const import _LOGGER, SENSOR_COLLECTORS_OPZET


class OpzetCollector(object):
Expand Down Expand Up @@ -33,9 +33,6 @@ def __init__(
TODAY = datetime.today().strftime("%d-%m-%Y")
self.DATE_TODAY = datetime.strptime(TODAY, "%d-%m-%Y")
self.DATE_TOMORROW = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta(days=1)
self.DATE_TODAY_NEXT_YEAR = (
self.DATE_TODAY.date() + timedelta(days=365)
).strftime("%Y-%m-%d")

(
self._waste_data_raw,
Expand Down
4 changes: 3 additions & 1 deletion custom_components/afvalwijzer/common/day_sensor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def __init__(
):
TODAY = datetime.today().strftime("%d-%m-%Y")

self.waste_data_formatted = waste_data_formatted
self.waste_data_formatted = sorted(
waste_data_formatted, key=lambda d: d["date"]
)
self.today_date = datetime.strptime(TODAY, "%d-%m-%Y")
self.tomorrow_date = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta(days=1)
self.day_after_tomorrow_date = datetime.strptime(TODAY, "%d-%m-%Y") + timedelta(
Expand Down
4 changes: 3 additions & 1 deletion custom_components/afvalwijzer/common/next_sensor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class NextSensorData(object):
# INIT
##########################################################################
def __init__(self, waste_data_after_date_selected, default_label):
self.waste_data_after_date_selected = waste_data_after_date_selected
self.waste_data_after_date_selected = sorted(
waste_data_after_date_selected, key=lambda d: d["date"]
)

TODAY = datetime.today().strftime("%d-%m-%Y")
self.today_date = datetime.strptime(TODAY, "%d-%m-%Y")
Expand Down

0 comments on commit 3a2e4c3

Please sign in to comment.