mirror of https://github.com/elk-zone/elk.git
refactor(account): improve joined time format
This commit is contained in:
parent
1194d56d09
commit
b656c6fda2
|
@ -5,10 +5,11 @@ const { account } = defineProps<{
|
||||||
account: Account
|
account: Account
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const createdAt = $computed(() => {
|
const createdAt = $(useFormattedDateTime(() => account.createdAt, {
|
||||||
const date = new Date(account.createdAt)
|
month: 'long',
|
||||||
return new Intl.DateTimeFormat('en-US', { month: 'long', day: 'numeric', year: 'numeric' }).format(date)
|
day: 'numeric',
|
||||||
})
|
year: 'numeric',
|
||||||
|
}))
|
||||||
|
|
||||||
const fields = $computed(() => {
|
const fields = $computed(() => {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { MaybeRef, UseTimeAgoOptions } from '@vueuse/core'
|
import type { MaybeComputedRef, UseTimeAgoOptions } from '@vueuse/core'
|
||||||
|
|
||||||
export const useFormattedDateTime = (
|
export const useFormattedDateTime = (
|
||||||
value: MaybeRef<string | Date | undefined>,
|
value: MaybeComputedRef<string | Date | undefined>,
|
||||||
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' },
|
options: Intl.DateTimeFormatOptions = { dateStyle: 'long', timeStyle: 'medium' },
|
||||||
) => {
|
) => {
|
||||||
const formatter = Intl.DateTimeFormat(undefined, options)
|
const formatter = Intl.DateTimeFormat(undefined, options)
|
||||||
|
|
Loading…
Reference in New Issue