ffplayout/plugins/dayjs.ts

32 lines
823 B
TypeScript
Raw Normal View History

import dayjs from 'dayjs'
import customParseFormat from 'dayjs/plugin/customParseFormat.js'
import LocalizedFormat from 'dayjs/plugin/localizedFormat.js'
2023-01-11 10:54:25 +01:00
import timezone from 'dayjs/plugin/timezone.js'
import utc from 'dayjs/plugin/utc.js'
2023-01-11 10:54:25 +01:00
2024-04-14 00:01:45 +02:00
import 'dayjs/locale/de'
import 'dayjs/locale/en'
import 'dayjs/locale/es'
import 'dayjs/locale/pt'
import 'dayjs/locale/ru'
2023-06-28 11:01:17 +02:00
declare module '#app' {
interface NuxtApp {
$dayjs(date?: dayjs.ConfigType): dayjs.Dayjs
}
2023-06-28 11:01:17 +02:00
}
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$dayjs(date?: dayjs.ConfigType): dayjs.Dayjs
}
2023-06-28 11:01:17 +02:00
}
2023-01-11 10:54:25 +01:00
export default defineNuxtPlugin((nuxtApp) => {
dayjs.extend(customParseFormat)
dayjs.extend(LocalizedFormat)
2023-01-11 10:54:25 +01:00
dayjs.extend(timezone)
dayjs.extend(utc)
2023-01-11 10:54:25 +01:00
nuxtApp.provide('dayjs', dayjs)
})