Skip to content

Commit

Permalink
fix: duration column time formatting m-sureshraj#20
Browse files Browse the repository at this point in the history
  • Loading branch information
soulchainer committed Oct 27, 2019
1 parent e0f59c3 commit 1134e82
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ exports.formatTimestampToDate = function(timestamp) {
};

exports.formatMs = function(ms) {
const seconds = Math.floor((ms / 1000) % 60);
const minutes = Math.floor((ms / (1000 * 60)) % 60);
const hours = Math.floor((ms / (1000 * 60 * 24)) % 60);
let formattedTime = '';
const seconds = Math.floor(ms / 1000) % 60;
const minutes = Math.floor(ms / (1000 * 60)) % 60;
const hours = Math.floor(ms / (1000 * 60 * 60));
const formattedTime = [];

if (hours) formattedTime += hours.toString(10).padStart(2, '0') + 'hrs, ';
if (minutes) formattedTime += minutes.toString(10).padStart(2, '0') + ' min, ';
if (seconds) formattedTime += seconds.toString(10).padStart(2, '0') + ' sec';
if (hours) formattedTime.push(hours.toString(10).padStart(2, '0')) + ' hrs';
if (minutes) formattedTime.push(minutes.toString(10).padStart(2, '0')) + ' min';
if (seconds) formattedTime.push(seconds.toString(10).padStart(2, '0')) + ' sec';

return formattedTime;
return formattedTime.join(', ');
};

0 comments on commit 1134e82

Please sign in to comment.