diff --git a/pages/profile/[id].vue b/pages/profile/[id].vue
index bcc1726c0..9a8db186a 100644
--- a/pages/profile/[id].vue
+++ b/pages/profile/[id].vue
@@ -222,13 +222,6 @@ function commaSeparated(n: number) {
return '0'
}
-function getTotalPlayTimeText(time: number) {
- const hours = Math.floor(time / 36000)
- const minutes = Math.floor((time % 36000) / 600)
- const seconds = Math.floor((time % 600) / 10)
- return `${hours}H ${minutes}M ${seconds}S`
-}
-
defineCytoidPage({
title: profileData.value?.profile?.user?.name ?? profileId,
background: profileData.value?.profile?.header?.original ?? undefined,
@@ -370,7 +363,7 @@ defineCytoidPage({
-
+
diff --git a/utils/date-locale.ts b/utils/date-locale.ts
index bf6f0d283..6f4b1a664 100644
--- a/utils/date-locale.ts
+++ b/utils/date-locale.ts
@@ -1,4 +1,4 @@
-import { formatDistanceToNow, formatRelative, parseISO } from 'date-fns'
+import { formatDistanceToNow, formatDuration, formatRelative, parseISO } from 'date-fns'
import { cs, de, enUS, es, fr, hu, id, ja, ko, ms, ptBR, ru, th, vi, zhCN, zhTW } from 'date-fns/locale'
@@ -45,3 +45,12 @@ export function dateFormatCalendar(dateStr: string, from = new Date()) {
},
)
}
+
+export function timeFormatDuration(seconds: number) {
+ const locale = useLocales().locale.value
+ return formatDuration({
+ hours: Math.floor(seconds / 3600),
+ minutes: Math.floor((seconds % 3600) / 60),
+ seconds: Math.floor(seconds % 60),
+ }, { locale: dateLocales[locale], zero: false })
+}