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