Skip to content

Commit

Permalink
Deploy 20240220
Browse files Browse the repository at this point in the history
fix: wrong total play text
  • Loading branch information
Teages authored Feb 19, 2024
2 parents fffd64c + 13ce64a commit b962fe9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 1 addition & 8 deletions pages/profile/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -370,7 +363,7 @@ defineCytoidPage({
<StatItem :title="$t('profile.highest_max_combo')" :data="commaSeparated(profileData.profile.activity.maxCombo)" />
<StatItem :title="$t('profile.avg_ranked_accuracy')" :data="`${truncateNum(profileData.profile.activity.averageRankedAccuracy * 100)}%`" />
<StatItem :title="$t('profile.total_ranked_score')" :data="commaSeparated(profileData.profile.activity.totalRankedScore)" />
<StatItem :title="$t('profile.total_play_time')" :data="getTotalPlayTimeText(profileData.profile.activity.totalPlayTime)" />
<StatItem :title="$t('profile.total_play_time')" :data="timeFormatDuration(profileData.profile.activity.totalPlayTime)" />
</div>
<div class="overflow-auto w-auto">
Expand Down
11 changes: 10 additions & 1 deletion utils/date-locale.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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 })
}

0 comments on commit b962fe9

Please sign in to comment.