diff --git a/frontend/src/components/MealPlan/MealPlanCard.vue b/frontend/src/components/MealPlan/MealPlanCard.vue
index 100aceced..9fffa6e47 100644
--- a/frontend/src/components/MealPlan/MealPlanCard.vue
+++ b/frontend/src/components/MealPlan/MealPlanCard.vue
@@ -17,7 +17,7 @@
:src="getImage(meal.slug)"
@click="openSearch(index)"
>
- {{ meal.dateText }}
+ {{ $d( new Date(meal.date), 'short' ) }}
{{ meal.name }}
diff --git a/frontend/src/components/MealPlan/MealPlanNew.vue b/frontend/src/components/MealPlan/MealPlanNew.vue
index 8eaaa4389..c5ec0d8b7 100644
--- a/frontend/src/components/MealPlan/MealPlanNew.vue
+++ b/frontend/src/components/MealPlan/MealPlanNew.vue
@@ -69,16 +69,14 @@
-
-
+
+
{{ $t("general.random") }}
-
+
{{ $t("general.save") }}
-
-
@@ -136,7 +134,7 @@ export default {
let dateDif = (endDate - startDate) / (1000 * 3600 * 24) + 1;
- if (dateDif <= 1) {
+ if (dateDif < 1) {
return null;
}
diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js
index 41d46703c..f5320dcc2 100644
--- a/frontend/src/i18n.js
+++ b/frontend/src/i18n.js
@@ -3,12 +3,8 @@ import VueI18n from "vue-i18n";
Vue.use(VueI18n);
-function loadLocaleMessages() {
- const locales = require.context(
- "./locales",
- true,
- /[A-Za-z0-9-_,\s]+\.json$/i
- );
+
+function parseLocaleFiles(locales) {
const messages = {};
locales.keys().forEach(key => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i);
@@ -20,8 +16,28 @@ function loadLocaleMessages() {
return messages;
}
+function loadLocaleMessages() {
+ const locales = require.context(
+ "./locales/messages",
+ true,
+ /[A-Za-z0-9-_,\s]+\.json$/i
+ );
+ return parseLocaleFiles(locales);
+}
+
+function loadDateTimeFormats() {
+ const locales = require.context(
+ "./locales/dateTimeFormats",
+ true,
+ /[A-Za-z0-9-_,\s]+\.json$/i
+ );
+ return parseLocaleFiles(locales);
+}
+
+
export default new VueI18n({
locale: "en",
fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en",
messages: loadLocaleMessages(),
+ dateTimeFormats: loadDateTimeFormats()
});
diff --git a/frontend/src/locales/dateTimeFormats/da.json b/frontend/src/locales/dateTimeFormats/da.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/da.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/de.json b/frontend/src/locales/dateTimeFormats/de.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/de.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/en.json b/frontend/src/locales/dateTimeFormats/en.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/en.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/fr.json b/frontend/src/locales/dateTimeFormats/fr.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/fr.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/pl.json b/frontend/src/locales/dateTimeFormats/pl.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/pl.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/sv.json b/frontend/src/locales/dateTimeFormats/sv.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/sv.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/zh-CN.json b/frontend/src/locales/dateTimeFormats/zh-CN.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/zh-CN.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/dateTimeFormats/zh-TW.json b/frontend/src/locales/dateTimeFormats/zh-TW.json
new file mode 100644
index 000000000..a0af56a4e
--- /dev/null
+++ b/frontend/src/locales/dateTimeFormats/zh-TW.json
@@ -0,0 +1,7 @@
+{
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+}
\ No newline at end of file
diff --git a/frontend/src/locales/da.json b/frontend/src/locales/messages/da.json
similarity index 100%
rename from frontend/src/locales/da.json
rename to frontend/src/locales/messages/da.json
diff --git a/frontend/src/locales/de.json b/frontend/src/locales/messages/de.json
similarity index 100%
rename from frontend/src/locales/de.json
rename to frontend/src/locales/messages/de.json
diff --git a/frontend/src/locales/en.json b/frontend/src/locales/messages/en.json
similarity index 98%
rename from frontend/src/locales/en.json
rename to frontend/src/locales/messages/en.json
index bdf4685ab..429f28e82 100644
--- a/frontend/src/locales/en.json
+++ b/frontend/src/locales/messages/en.json
@@ -1,4 +1,12 @@
{
+
+ "dateTimeFormats": {
+ "short": {
+ "month": "short",
+ "day": "numeric",
+ "weekday": "long"
+ }
+ },
"404": {
"page-not-found": "404 Page Not Found",
"take-me-home": "Take me Home"
diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/messages/fr.json
similarity index 100%
rename from frontend/src/locales/fr.json
rename to frontend/src/locales/messages/fr.json
diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/messages/pl.json
similarity index 100%
rename from frontend/src/locales/pl.json
rename to frontend/src/locales/messages/pl.json
diff --git a/frontend/src/locales/sv.json b/frontend/src/locales/messages/sv.json
similarity index 100%
rename from frontend/src/locales/sv.json
rename to frontend/src/locales/messages/sv.json
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/messages/zh-CN.json
similarity index 100%
rename from frontend/src/locales/zh-CN.json
rename to frontend/src/locales/messages/zh-CN.json
diff --git a/frontend/src/locales/zh-TW.json b/frontend/src/locales/messages/zh-TW.json
similarity index 100%
rename from frontend/src/locales/zh-TW.json
rename to frontend/src/locales/messages/zh-TW.json
diff --git a/frontend/src/pages/MealPlanPage.vue b/frontend/src/pages/MealPlanPage.vue
index 90d583d2a..eb87f34b7 100644
--- a/frontend/src/pages/MealPlanPage.vue
+++ b/frontend/src/pages/MealPlanPage.vue
@@ -25,8 +25,8 @@
>
- {{ formatDate(mealplan.startDate) }} -
- {{ formatDate(mealplan.endDate) }}
+ {{ $d( new Date(mealplan.startDate), 'short' ) }} -
+ {{ $d( new Date(mealplan.endDate), 'short' ) }}
@@ -43,7 +43,7 @@
-
+
diff --git a/frontend/src/pages/MealPlanThisWeekPage.vue b/frontend/src/pages/MealPlanThisWeekPage.vue
index c61cfa232..aacec5312 100644
--- a/frontend/src/pages/MealPlanThisWeekPage.vue
+++ b/frontend/src/pages/MealPlanThisWeekPage.vue
@@ -18,7 +18,7 @@
{{ meal.name }}
- {{ meal.dateText }}
+ {{ $d(new Date(meal.date), 'short' ) }}
{{ meal.description }}
diff --git a/frontend/src/store/modules/userSettings.js b/frontend/src/store/modules/userSettings.js
index 59a210dfb..b961525b3 100644
--- a/frontend/src/store/modules/userSettings.js
+++ b/frontend/src/store/modules/userSettings.js
@@ -63,6 +63,7 @@ const actions = {
}
},
+
async initTheme({ dispatch, getters }) {
//If theme is empty resetTheme
if (Object.keys(getters.getActiveTheme).length === 0) {
diff --git a/mealie/services/meal_services.py b/mealie/services/meal_services.py
index a723b3fde..d681112b1 100644
--- a/mealie/services/meal_services.py
+++ b/mealie/services/meal_services.py
@@ -2,7 +2,7 @@ from datetime import date, timedelta
from typing import List, Optional
from db.database import db
-from pydantic import BaseModel
+from pydantic import BaseModel, validator
from sqlalchemy.orm.session import Session
from services.recipe_services import Recipe
@@ -41,6 +41,12 @@ class MealPlan(BaseModel):
}
}
+ @validator('endDate')
+ def endDate_after_startDate(cls, v, values, **kwargs):
+ if 'startDate' in values and v < values['startDate']:
+ raise ValueError('EndDate should be greater than StartDate')
+ return v
+
def process_meals(self, session: Session):
meals = []
for x, meal in enumerate(self.meals):