Skip to content

Commit cf0d2c8

Browse files
jj19100chenyingjie
and
chenyingjie
authored
fix: build time display 7m 60s (#19108)
Co-authored-by: chenyingjie <[email protected]>
1 parent da0caf5 commit cf0d2c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/vite/src/node/utils.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1501,11 +1501,17 @@ export function displayTime(time: number): string {
15011501
return `${time.toFixed(2)}s`
15021502
}
15031503

1504-
const mins = parseInt((time / 60).toString())
1505-
const seconds = time % 60
1504+
// Calculate total minutes and remaining seconds
1505+
const mins = Math.floor(time / 60)
1506+
const seconds = Math.round(time % 60)
1507+
1508+
// Handle case where seconds rounds to 60
1509+
if (seconds === 60) {
1510+
return `${mins + 1}m`
1511+
}
15061512

15071513
// display: {X}m {Y}s
1508-
return `${mins}m${seconds < 1 ? '' : ` ${seconds.toFixed(0)}s`}`
1514+
return `${mins}m${seconds < 1 ? '' : ` ${seconds}s`}`
15091515
}
15101516

15111517
/**

0 commit comments

Comments
 (0)