2022-11-25 09:57:34 +01:00
|
|
|
import type { MaybeRef } from '@vueuse/core'
|
|
|
|
|
|
|
|
export const useFormattedDateTime = (
|
2022-11-26 04:36:18 +01:00
|
|
|
value: MaybeRef<string | Date | undefined>,
|
2022-11-25 09:57:34 +01:00
|
|
|
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' },
|
|
|
|
) => {
|
|
|
|
const formatter = Intl.DateTimeFormat(undefined, options)
|
2022-11-26 04:36:18 +01:00
|
|
|
return computed(() => {
|
|
|
|
const v = resolveUnref(value)
|
|
|
|
return v ? formatter.format(new Date(v)) : ''
|
|
|
|
})
|
2022-11-25 09:57:34 +01:00
|
|
|
}
|