fix timezone bug in recipe mealplan dialog

This commit is contained in:
Michael Genson 2025-07-18 21:20:02 +00:00
commit a099c87500

View file

@ -269,13 +269,17 @@ export default defineNuxtComponent({
recipeName: props.name, recipeName: props.name,
loading: false, loading: false,
menuItems: [] as ContextMenuItem[], menuItems: [] as ContextMenuItem[],
newMealdate: new Date(Date.now() - new Date().getTimezoneOffset() * 60000), newMealdate: new Date(),
newMealType: "dinner" as PlanEntryType, newMealType: "dinner" as PlanEntryType,
pickerMenu: false, pickerMenu: false,
}); });
const newMealdateString = computed(() => { const newMealdateString = computed(() => {
return state.newMealdate.toISOString().substring(0, 10); // Format the date to YYYY-MM-DD in the same timezone as newMealdate
const year = state.newMealdate.getFullYear();
const month = String(state.newMealdate.getMonth() + 1).padStart(2, '0');
const day = String(state.newMealdate.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}); });
const i18n = useI18n(); const i18n = useI18n();