diff --git a/mealie/repos/repository_meals.py b/mealie/repos/repository_meals.py index ec6a35076a5..d1afec251fd 100644 --- a/mealie/repos/repository_meals.py +++ b/mealie/repos/repository_meals.py @@ -9,11 +9,11 @@ class RepositoryMeals(HouseholdRepositoryGeneric[ReadPlanEntry, GroupMealPlan]): - def get_today(self) -> list[ReadPlanEntry]: + def get_today(self, tz=UTC) -> list[ReadPlanEntry]: if not self.household_id: raise Exception("household_id not set") - today = datetime.now(tz=UTC).date() + today = datetime.now(tz=tz).date() stmt = select(GroupMealPlan).filter( GroupMealPlan.date == today, GroupMealPlan.household_id == self.household_id ) diff --git a/mealie/routes/households/controller_mealplan.py b/mealie/routes/households/controller_mealplan.py index c039cb97383..2055f062d00 100644 --- a/mealie/routes/households/controller_mealplan.py +++ b/mealie/routes/households/controller_mealplan.py @@ -1,6 +1,7 @@ from datetime import date from functools import cached_property +from dateutil.tz import tzlocal from fastapi import APIRouter, Depends, HTTPException from mealie.core.exceptions import mealie_registered_exceptions @@ -115,7 +116,8 @@ def create_one(self, data: CreatePlanEntry): @router.get("/today") def get_todays_meals(self): - return self.repo.get_today() + local_tz = tzlocal() + return self.repo.get_today(tz=local_tz) @router.post("/random", response_model=ReadPlanEntry) def create_random_meal(self, data: CreateRandomEntry): diff --git a/mealie/services/scheduler/tasks/create_timeline_events.py b/mealie/services/scheduler/tasks/create_timeline_events.py index 1806e1217f2..8eb1cde5bb4 100644 --- a/mealie/services/scheduler/tasks/create_timeline_events.py +++ b/mealie/services/scheduler/tasks/create_timeline_events.py @@ -1,5 +1,6 @@ from datetime import UTC, datetime, time, timedelta +from dateutil.tz import tzlocal from pydantic import UUID4 from sqlalchemy.orm import Session @@ -29,7 +30,8 @@ def _create_mealplan_timeline_events_for_household( recipes_to_update: dict[UUID4, RecipeSummary] = {} recipe_id_to_slug_map: dict[UUID4, str] = {} - mealplans = repos.meals.get_today() + local_tz = tzlocal() + mealplans = repos.meals.get_today(tz=local_tz) for mealplan in mealplans: if not (mealplan.recipe and mealplan.user_id): continue