Display: Format date with app locale - refs BT#21766

pull/5671/head
Angel Fernando Quiroz Campos 4 months ago
parent bac988186b
commit 7a3f4251e2
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 11
      assets/vue/composables/formatDate.js
  2. 3
      assets/vue/composables/locale.js

@ -1,18 +1,23 @@
const { DateTime } = require("luxon")
import { DateTime } from "luxon"
import { useLocale } from "./locale"
export function useFormatDate() {
const { appParentLocale } = useLocale()
const abbreviatedDatetime = (datetime) => {
if (!datetime) {
return ""
}
return DateTime.fromISO(datetime).toLocaleString({
return DateTime.fromISO(datetime)
.setLocale(appParentLocale.value)
.toLocaleString({
...DateTime.DATETIME_MED,
month: "long",
})
}
const relativeDatetime = (datetime) => DateTime.fromISO(datetime).toRelative()
const relativeDatetime = (datetime) => DateTime.fromISO(datetime).setLocale(appParentLocale.value).toRelative()
return {
abbreviatedDatetime,

@ -84,8 +84,11 @@ export function useLocale() {
window.location.href = newUrl.fullPath
}
const appParentLocale = computed(() => useParentLocale(appLocale.value))
return {
appLocale,
appParentLocale,
languageList,
currentLanguageFromList,
reloadWithLocale,

Loading…
Cancel
Save