Enhance playtime formatting to include hours and minutes; update localization for time in English and Chinese
This commit is contained in:
15
src/App.tsx
15
src/App.tsx
@@ -122,15 +122,18 @@ function App() {
|
||||
.catch(error => console.error('Error fetching top players:', error))
|
||||
}, [])
|
||||
|
||||
// Format playtime from seconds to hours
|
||||
// Format playtime from seconds to hours and minutes
|
||||
const formatPlayTime = (seconds: number) => {
|
||||
const hours = Math.floor(seconds / 3600)
|
||||
if (hours >= 1000000) {
|
||||
return `${(hours / 1000000).toFixed(1)}M`
|
||||
} else if (hours >= 1000) {
|
||||
return `${(hours / 1000).toFixed(1)}K`
|
||||
const minutes = Math.floor((seconds % 3600) / 60)
|
||||
|
||||
if (hours > 0) {
|
||||
if (minutes > 0) {
|
||||
return `${hours}${t('time.hours')} ${minutes}${t('time.minutes')}`
|
||||
}
|
||||
return `${hours}${t('time.hours')}`
|
||||
}
|
||||
return hours.toLocaleString()
|
||||
return `${minutes}${t('time.minutes')}`
|
||||
}
|
||||
|
||||
// Format time ago from timestamp
|
||||
|
||||
@@ -51,13 +51,9 @@
|
||||
"joinForum": "Join Forum",
|
||||
"viewFriends": "View Friends"
|
||||
},
|
||||
"activity": {
|
||||
"title": "Recent Activity",
|
||||
"topPlayers": "Top Players by Playtime",
|
||||
"serverInfo": "Server Info",
|
||||
"serverStatus": "Status: Online ✓",
|
||||
"currentMap": "Map: de_dust2",
|
||||
"nextRestart": "Restart: 6h 30m"
|
||||
"time": {
|
||||
"hours": "h",
|
||||
"minutes": "m"
|
||||
},
|
||||
"footer": {
|
||||
"community": "🎯 CS Community",
|
||||
|
||||
@@ -50,13 +50,9 @@
|
||||
"joinForum": "加入论坛",
|
||||
"viewFriends": "查看友链"
|
||||
},
|
||||
"activity": {
|
||||
"title": "最近活动",
|
||||
"topPlayers": "游戏时长排行榜",
|
||||
"serverInfo": "服务器信息",
|
||||
"serverStatus": "状态:在线 ✓",
|
||||
"currentMap": "地图:de_dust2",
|
||||
"nextRestart": "重启:6小时30分钟"
|
||||
"time": {
|
||||
"hours": "小时",
|
||||
"minutes": "分钟"
|
||||
},
|
||||
"footer": {
|
||||
"community": "🎯 CS 社区",
|
||||
|
||||
Reference in New Issue
Block a user