add props diffNow, add computed dateString

This commit is contained in:
ogerly 2022-03-16 18:32:28 +01:00
parent 0bba201d33
commit 54b7e58a5e

View File

@ -2,12 +2,11 @@
<div class="date-row"> <div class="date-row">
<b-row> <b-row>
<b-col cols="5"> <b-col cols="5">
<div class="text-right">{{ $t('form.date') }}</div> <div class="text-right">{{ diffNow ? $t('gdd_per_link.expired') : $t('form.date') }}</div>
</b-col> </b-col>
<b-col cols="7"> <b-col cols="7">
<div class="gdd-transaction-list-item-date"> <div class="gdd-transaction-list-item-date">
{{ $d(new Date(balanceDate), 'long') }} {{ dateString }}
{{ $i18n.locale === 'de' ? 'Uhr' : '' }}
</div> </div>
</b-col> </b-col>
</b-row> </b-row>
@ -17,10 +16,22 @@
export default { export default {
name: 'DateRow', name: 'DateRow',
props: { props: {
balanceDate: { date: {
type: String, type: String,
required: true, required: true,
}, },
diffNow: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
dateString() {
return this.diffNow
? this.$moment(this.date).locale(this.$i18n.locale).fromNow()
: this.$d(new Date(this.date), 'long')
},
}, },
} }
</script> </script>