From 66a1377db2fcb5f1fcec2b0511bf1784fb93354a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 20 Jan 2022 13:21:19 +0100 Subject: [PATCH] fix: Localize Datetime in Admin Interface --- admin/src/components/CreationFormular.vue | 49 ++++++++++++++--------- admin/src/i18n.js | 18 +++++++++ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/admin/src/components/CreationFormular.vue b/admin/src/components/CreationFormular.vue index 49993d14a..5b6ca7553 100644 --- a/admin/src/components/CreationFormular.vue +++ b/admin/src/components/CreationFormular.vue @@ -15,7 +15,7 @@ @change="updateRadioSelected(beforeLastMonth, 0, creation[0])" > @@ -29,7 +29,7 @@ @change="updateRadioSelected(lastMonth, 1, creation[1])" > @@ -43,7 +43,7 @@ @change="updateRadioSelected(currentMonth, 2, creation[2])" > @@ -169,24 +169,10 @@ export default { value: !this.creationUserData.amount ? 0 : this.creationUserData.amount, rangeMin: 0, rangeMax: 1000, - currentMonth: { - short: this.$moment().format('MMMM'), - long: this.$moment().format('YYYY-MM-DD'), - year: this.$moment().format('YYYY'), - }, - lastMonth: { - short: this.$moment().subtract(1, 'month').format('MMMM'), - long: this.$moment().subtract(1, 'month').format('YYYY-MM') + '-01', - year: this.$moment().subtract(1, 'month').format('YYYY'), - }, - beforeLastMonth: { - short: this.$moment().subtract(2, 'month').format('MMMM'), - long: this.$moment().subtract(2, 'month').format('YYYY-MM') + '-01', - year: this.$moment().subtract(2, 'month').format('YYYY'), - }, submitObj: null, isdisabled: true, createdIndex: null, + now: Date.now(), } }, @@ -298,6 +284,33 @@ export default { }) }, }, + computed: { + currentMonth() { + return { + short: this.$d(this.now, 'month'), + long: this.$d(this.now, 'short'), + year: this.$d(this.now, 'year'), + } + }, + lastMonth() { + const now = new Date(this.now) + const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1) + return { + short: this.$d(lastMonth, 'month'), + long: this.$d(lastMonth, 'short'), + year: this.$d(lastMonth, 'year'), + } + }, + beforeLastMonth() { + const now = new Date(this.now) + const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1) + return { + short: this.$d(beforeLastMonth, 'month'), + long: this.$d(beforeLastMonth, 'short'), + year: this.$d(beforeLastMonth, 'year'), + } + }, + }, created() { this.searchModeratorData() }, diff --git a/admin/src/i18n.js b/admin/src/i18n.js index 14e81543e..6291a9c6c 100644 --- a/admin/src/i18n.js +++ b/admin/src/i18n.js @@ -60,6 +60,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, de: { short: { @@ -75,6 +84,15 @@ const dateTimeFormats = { hour: 'numeric', minute: 'numeric', }, + monthShort: { + month: 'short', + }, + month: { + month: 'long', + }, + year: { + year: 'numeric', + }, }, }