Skip to content

Commit e5f9ef4

Browse files
committed
fix: use <NuxtTime> for locale-await time elements
1 parent dd1e46f commit e5f9ef4

2 files changed

Lines changed: 26 additions & 30 deletions

File tree

app/components/PackageVersions.vue

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,6 @@ function toggleMajorGroup(index: number) {
290290
function getTagVersions(tag: string): VersionDisplay[] {
291291
return tagVersions.value.get(tag) ?? []
292292
}
293-
294-
function formatDate(dateStr: string): string {
295-
return new Date(dateStr).toLocaleDateString('en-US', {
296-
year: 'numeric',
297-
month: 'short',
298-
day: 'numeric',
299-
})
300-
}
301293
</script>
302294

303295
<template>
@@ -341,13 +333,14 @@ function formatDate(dateStr: string): string {
341333
{{ row.primaryVersion.version }}
342334
</NuxtLink>
343335
<div class="flex items-center gap-2 shrink-0">
344-
<time
336+
<NuxtTime
345337
v-if="row.primaryVersion.time"
346338
:datetime="row.primaryVersion.time"
339+
year="numeric"
340+
month="short"
341+
day="numeric"
347342
class="text-xs text-fg-subtle"
348-
>
349-
{{ formatDate(row.primaryVersion.time) }}
350-
</time>
343+
/>
351344
<ProvenanceBadge
352345
v-if="row.primaryVersion.hasProvenance"
353346
:package-name="packageName"
@@ -384,9 +377,14 @@ function formatDate(dateStr: string): string {
384377
{{ v.version }}
385378
</NuxtLink>
386379
<div class="flex items-center gap-2 shrink-0">
387-
<time v-if="v.time" :datetime="v.time" class="text-[10px] text-fg-subtle">
388-
{{ formatDate(v.time) }}
389-
</time>
380+
<NuxtTime
381+
v-if="v.time"
382+
:datetime="v.time"
383+
class="text-[10px] text-fg-subtle"
384+
year="numeric"
385+
month="short"
386+
day="numeric"
387+
/>
390388
<ProvenanceBadge
391389
v-if="v.hasProvenance"
392390
:package-name="packageName"
@@ -451,13 +449,14 @@ function formatDate(dateStr: string): string {
451449
{{ row.primaryVersion.version }}
452450
</NuxtLink>
453451
<div class="flex items-center gap-2 shrink-0">
454-
<time
452+
<NuxtTime
455453
v-if="row.primaryVersion.time"
456454
:datetime="row.primaryVersion.time"
457455
class="text-[10px] text-fg-subtle"
458-
>
459-
{{ formatDate(row.primaryVersion.time) }}
460-
</time>
456+
year="numeric"
457+
month="short"
458+
day="numeric"
459+
/>
461460
</div>
462461
</div>
463462
<div v-if="row.tags.length" class="flex items-center gap-1 mt-0.5 flex-wrap">
@@ -543,9 +542,14 @@ function formatDate(dateStr: string): string {
543542
{{ v.version }}
544543
</NuxtLink>
545544
<div class="flex items-center gap-2 shrink-0">
546-
<time v-if="v.time" :datetime="v.time" class="text-[10px] text-fg-subtle">
547-
{{ formatDate(v.time) }}
548-
</time>
545+
<NuxtTime
546+
v-if="v.time"
547+
:datetime="v.time"
548+
class="text-[10px] text-fg-subtle"
549+
year="numeric"
550+
month="short"
551+
day="numeric"
552+
/>
549553
<ProvenanceBadge
550554
v-if="v.hasProvenance"
551555
:package-name="packageName"

app/utils/formatters.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@ export function formatNumber(num: number): string {
22
return new Intl.NumberFormat('en-US').format(num)
33
}
44

5-
export function formatDate(dateStr: string): string {
6-
return new Date(dateStr).toLocaleDateString('en-US', {
7-
year: 'numeric',
8-
month: 'short',
9-
day: 'numeric',
10-
})
11-
}
12-
135
export function toIsoDateString(date: Date): string {
146
const year = date.getUTCFullYear()
157
const month = String(date.getUTCMonth() + 1).padStart(2, '0')

0 commit comments

Comments
 (0)