fix: progress bar NaN (#532)

Update utils.js
This commit is contained in:
DIYgod 2019-09-23 18:53:47 +08:00 committed by GitHub
commit 8ddca4e84b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -9,6 +9,10 @@ const utils = {
* @return {String} 00:00 or 00:00:00
*/
secondToTime: (second) => {
second = second || 0;
if (second === 0 || second == Infinity || second.toString() === 'NaN') {
return '00:00'
}
const add0 = (num) => num < 10 ? '0' + num : '' + num;
const hour = Math.floor(second / 3600);
const min = Math.floor((second - hour * 3600) / 60);
@ -146,4 +150,4 @@ const utils = {
},
};
export default utils;
export default utils;