vuetify-nuxt-module icon indicating copy to clipboard operation
vuetify-nuxt-module copied to clipboard

UseDate().format is not able to find locale

Open skoenfaelt opened this issue 6 months ago • 0 comments

  • Using a base layer as npm package witrh preconfigureed i18n and vuetify
  • in my app I add additional i18n, vuetify based on the project

the script and template const { date, format: formatDate } = useDate() {{ formatDate(date(auftrag.xyz[0].datestring), 'keyboardDate') }}

If I run the app in dev mode, everything works just perfect. As soon as I build the app and start it I get "Cannot read properties of undefined (reading 'locale')"

where the error occurs

format(t, n) {
        return WP(t, n, this.locale, this.formats)
    }

minified call:

 m( () => [w("div", mt, [w("div", vt, [c[0] || (c[0] = w("span", null, "Datum: ", -1)), E(" " + F(a(h)(a(g)(t.auftrag.xyz[0].datestring), "keyboardDate")), 1)])

so its 100% the format of useDate composable.

I tried different date adapters, vuetify, luxon, dayJs. A reproduction is hard to recreate. Are there any special configs I need to look into?

If used with DayJs I get this error: Cannot read properties of undefined (reading 'dayjs')


If I use native Luxon adapter

  import { DateTime } from 'luxon'

  const { locale } = useI18n()
  const formatDate = (dateString: string) => {
    return DateTime.fromISO(dateString).setLocale(locale.value).toLocaleString(DateTime.DATE_MED)
  }

then everything works.

skoenfaelt avatar Jul 15 '25 06:07 skoenfaelt