Skip to content

Commit

Permalink
修复最后运行时长多语言显示
Browse files Browse the repository at this point in the history
  • Loading branch information
whyour committed Jan 31, 2025
1 parent 25e8e81 commit 952ea28
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Intl from 'react-intl-universal';

export function diffTime(num: number) {
const diff = num * 1000;

Expand All @@ -12,15 +14,15 @@ export function diffTime(num: number) {
const leave3 = leave2 % (60 * 1000);
const seconds = Math.round(leave3 / 1000);

let returnStr = seconds + '秒';
let returnStr = `${seconds} ${Intl.get('秒')}`;
if (minutes > 0) {
returnStr = minutes + '分' + returnStr;
returnStr = `${minutes} ${Intl.get('分')} ` + returnStr;
}
if (hours > 0) {
returnStr = hours + '小时' + returnStr;
returnStr = `${hours} ${Intl.get('时')} ` + returnStr;
}
if (days > 0) {
returnStr = days + '天' + returnStr;
returnStr = `${days} ${Intl.get('天')} ` + returnStr;
}
return returnStr;
}

0 comments on commit 952ea28

Please sign in to comment.