Skip to content
Snippets Groups Projects
Commit 9c320cea authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: add ATime component

parent 0cbb30d9
No related branches found
No related tags found
No related merge requests found
<template>
<time :datetime="isoRepresentation" :title="title">
<slot :datetime="datetime" />
</time>
</template>
<script lang="ts" setup>
import { parseISO } from 'date-fns'
import { computed } from 'vue'
import { useI18n } from '@/i18n'
const props = defineProps<{
time: Date | string
}>()
const { locale } = useI18n()
const datetime = computed(() => (props.time instanceof Date ? props.time : parseISO(props.time)))
const isoRepresentation = computed(() =>
typeof props.time === 'string' ? props.time : props.time.toISOString(),
)
const title = computed(() =>
datetime.value.toLocaleString(locale.value, { dateStyle: 'full', timeStyle: 'medium' }),
)
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment