bigbluebutton-Github/bigbluebutton-html5/imports/utils/humanizeSeconds.js

19 lines
481 B
JavaScript
Raw Normal View History

2017-06-03 03:25:02 +08:00
const humanizeSeconds = (time) => {
const hours = Math.floor(time / 3600);
const minutes = Math.floor((time % 3600) / 60);
2016-11-29 03:48:02 +08:00
const seconds = time % 60;
const formatNumber = (num) => {
if (num < 10) {
return `0${num}`;
2017-10-06 20:50:01 +08:00
}
return num.toString();
};
if (hours > 0) {
return `${formatNumber(hours)}:${formatNumber(minutes)}:${formatNumber(seconds)}`;
}
return `${formatNumber(minutes)}:${formatNumber(seconds)}`;
2016-11-29 03:48:02 +08:00
};
2017-10-24 00:26:56 +08:00
export default humanizeSeconds;