Skip to content

Commit d964fd7

Browse files
authoredNov 28, 2024··
fix: initialise formatter for relative formats in prehydrate step (#310)
1 parent 32456c2 commit d964fd7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed
 

Diff for: ‎src/runtime/components/NuxtTime.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ if (import.meta.server) {
122122
{ unit: 'year', value: diffInSeconds / 31536000 },
123123
]
124124
const { unit, value } = units.find(({ value }) => Math.abs(value) < 60) || units[units.length - 1]!
125-
el.textContent = formatter.value.format(Math.round(value), unit)
125+
const formatter = new Intl.RelativeTimeFormat(options.locale, options)
126+
el.textContent = formatter.format(Math.round(value), unit)
126127
}
127128
else {
128129
const formatter = new Intl.DateTimeFormat(options.locale, options)

0 commit comments

Comments
 (0)
Please sign in to comment.