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

pull/5671/head
Angel Fernando Quiroz Campos 1 year 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() { export function useFormatDate() {
const { appParentLocale } = useLocale()
const abbreviatedDatetime = (datetime) => { const abbreviatedDatetime = (datetime) => {
if (!datetime) { if (!datetime) {
return "" return ""
} }
return DateTime.fromISO(datetime).toLocaleString({ return DateTime.fromISO(datetime)
.setLocale(appParentLocale.value)
.toLocaleString({
...DateTime.DATETIME_MED, ...DateTime.DATETIME_MED,
month: "long", month: "long",
}) })
} }
const relativeDatetime = (datetime) => DateTime.fromISO(datetime).toRelative() const relativeDatetime = (datetime) => DateTime.fromISO(datetime).setLocale(appParentLocale.value).toRelative()
return { return {
abbreviatedDatetime, abbreviatedDatetime,

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

Loading…
Cancel
Save