Skip to content

Commit

Permalink
[Update] updated mstoTime function
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Sep 30, 2021
1 parent 21481e7 commit a3d0d32
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/mstoTime.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module.exports.msToTime = (duration) => {
let milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
seconds = parseInt((duration / 1000) % 60),
minutes = parseInt((duration / (1000 * 60)) % 60),
hours = parseInt((duration / (1000 * 60 * 60)) % 24);

hours = hours < 10 ? "0" + hours : hours;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;

return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
if (duration < 3600000) {
return minutes + ":" + seconds;
} else {
return hours + ":" + minutes + ":" + seconds;
}
};

0 comments on commit a3d0d32

Please sign in to comment.