(startTime: number, endTime?: number)
| 81 | } |
| 82 | |
| 83 | export const formatDuration = (startTime: number, endTime?: number): string => { |
| 84 | const duration = endTime ? endTime - startTime : Date.now() - startTime |
| 85 | const seconds = Math.floor(duration / 1000) |
| 86 | const minutes = Math.floor(seconds / 60) |
| 87 | const hours = Math.floor(minutes / 60) |
| 88 | |
| 89 | if (hours > 0) { |
| 90 | return `${hours}小时${minutes % 60}分钟` |
| 91 | } else if (minutes > 0) { |
| 92 | return `${minutes}分钟${seconds % 60}秒` |
| 93 | } else { |
| 94 | return `${seconds}秒` |
| 95 | } |
| 96 | } |
nothing calls this directly
no outgoing calls
no test coverage detected