From 437c9aeaf975aea79f9dbe165413b6108e04bcad Mon Sep 17 00:00:00 2001 From: Giga77 <2777446+Giga77@users.noreply.github.com> Date: Tue, 3 Sep 2024 21:56:58 +0200 Subject: [PATCH 1/2] Fix timetable week begin --- .../ecole_directe/coordinator.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/custom_components/ecole_directe/coordinator.py b/custom_components/ecole_directe/coordinator.py index 985d3a5..39712d3 100644 --- a/custom_components/ecole_directe/coordinator.py +++ b/custom_components/ecole_directe/coordinator.py @@ -72,10 +72,21 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]: year_data = f"{str(current_year)}-{str(current_year + 1)}" # EDT BODY - today = datetime.today().strftime("%Y-%m-%d") - tomorrow = (datetime.today() + timedelta(days=1)).strftime("%Y-%m-%d") - current_week_begin = datetime.today() - timedelta( - days=datetime.today().weekday() + today = ( + datetime.now() + .replace(hour=0, minute=0, second=0, microsecond=0) + .strftime("%Y-%m-%d") + ) + tomorrow = ( + datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) + + timedelta(days=1) + ).strftime("%Y-%m-%d") + current_week_begin = datetime.now().replace( + hour=0, minute=0, second=0, microsecond=0 + ) - timedelta( + days=datetime.now() + .replace(hour=0, minute=0, second=0, microsecond=0) + .weekday() ) current_week_plus_21 = current_week_begin + timedelta(days=21) current_week_end = current_week_begin + timedelta(days=6) From dc6bc672754db595bc3fe8ff29404908e49dfe44 Mon Sep 17 00:00:00 2001 From: Giga77 <2777446+Giga77@users.noreply.github.com> Date: Tue, 3 Sep 2024 22:03:17 +0200 Subject: [PATCH 2/2] Fix school year range --- custom_components/ecole_directe/coordinator.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/custom_components/ecole_directe/coordinator.py b/custom_components/ecole_directe/coordinator.py index 39712d3..c4f18c8 100644 --- a/custom_components/ecole_directe/coordinator.py +++ b/custom_components/ecole_directe/coordinator.py @@ -66,10 +66,10 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]: self.data["session"] = session current_year = datetime.now().year - if (current_year % 2) == 0: - year_data = f"{str(current_year-1)}-{str(current_year)}" - else: + if datetime.now().month >= 8: year_data = f"{str(current_year)}-{str(current_year + 1)}" + else: + year_data = f"{str(current_year - 1)}-{str(current_year)}" # EDT BODY today = (