mirror of
https://github.com/elk-zone/elk.git
synced 2024-09-06 12:19:08 +01:00
13 lines
398 B
TypeScript
13 lines
398 B
TypeScript
import type { MaybeRef } from '@vueuse/core'
|
|
|
|
export const useFormattedDateTime = (
|
|
value: MaybeRef<string | Date | undefined>,
|
|
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' },
|
|
) => {
|
|
const formatter = Intl.DateTimeFormat(undefined, options)
|
|
return computed(() => {
|
|
const v = resolveUnref(value)
|
|
return v ? formatter.format(new Date(v)) : ''
|
|
})
|
|
}
|