remove moment. localize date time

This commit is contained in:
Moriz Wahl 2022-01-20 13:42:25 +01:00
parent af2ea3e809
commit 5e78e4ad07
2 changed files with 26 additions and 22 deletions

View File

@ -20,16 +20,7 @@ const toastedSuccessMock = jest.fn()
const mocks = {
$t: jest.fn((t) => t),
$moment: jest.fn(() => {
return {
format: jest.fn((m) => m),
subtract: jest.fn(() => {
return {
format: jest.fn((m) => m),
}
}),
}
}),
$d: jest.fn((d) => d),
$apollo: {
mutate: apolloMutateMock,
},

View File

@ -154,22 +154,11 @@ 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'),
},
lastMonth: {
short: this.$moment().subtract(1, 'month').format('MMMM'),
long: this.$moment().subtract(1, 'month').format('YYYY-MM') + '-01',
},
beforeLastMonth: {
short: this.$moment().subtract(2, 'month').format('MMMM'),
long: this.$moment().subtract(2, 'month').format('YYYY-MM') + '-01',
},
submitObj: null,
isdisabled: true,
createdIndex: null,
selectedOpenCreationAmount: {},
now: Date.now(),
}
},
@ -227,6 +216,30 @@ export default {
})
},
},
computed: {
currentMonth() {
return {
short: this.$d(this.now, 'month'),
long: this.$d(this.now, 'short'),
}
},
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'),
}
},
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'),
}
},
},
created() {
if (this.creationUserData.date) {
switch (this.$moment(this.creationUserData.date).format('MMMM')) {