Use app locale with toLocaleString/toLocaleDateString

Fixes inconsistent date formatting when browser language is different
from PleromaFE language.
This commit is contained in:
rinpatch 2020-12-03 00:17:55 +03:00
parent 0358284ebf
commit 60a8a89f5b
3 changed files with 9 additions and 4 deletions

View file

@ -9,6 +9,7 @@
<script>
import * as DateUtils from 'src/services/date_utils/date_utils.js'
import localeService from 'src/services/locale/locale.service.js'
export default {
name: 'Timeago',
@ -21,9 +22,10 @@ export default {
},
computed: {
localeDateString () {
const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
return typeof this.time === 'string'
? new Date(Date.parse(this.time)).toLocaleString()
: this.time.toLocaleString()
? new Date(Date.parse(this.time)).toLocaleString(browserLocale)
: this.time.toLocaleString(browserLocale)
}
},
created () {