Skip to content

Commit acd8dbb

Browse files
committed
feat: format DateTime title
1 parent 201f475 commit acd8dbb

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

app/components/DateTime.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ const { locale } = useI18n()
3333
3434
const relativeDates = useRelativeDates()
3535
36+
const dateFormatter = new Intl.DateTimeFormat(locale.value, {
37+
month: 'short',
38+
day: 'numeric',
39+
year: 'numeric',
40+
hour: 'numeric',
41+
minute: '2-digit',
42+
timeZoneName: 'short',
43+
})
44+
3645
// Compute the title - always show full date for accessibility
3746
const titleValue = computed(() => {
3847
if (props.title) return props.title
39-
if (typeof props.datetime === 'string') return props.datetime
40-
return props.datetime.toISOString()
48+
const date = typeof props.datetime === 'string' ? new Date(props.datetime) : props.datetime
49+
return dateFormatter.format(date)
4150
})
4251
</script>
4352

0 commit comments

Comments
 (0)