Skip to content

Commit

Permalink
using moment.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mmattel committed Apr 8, 2020
1 parent f471489 commit 2684e45
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/scripts/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,14 @@ const helper = {
},

getDisplayTime (time) {
if (time === 0) return "00:00";

if (time === 0) {
return "00:00";
}
// when switching between previews, currentTime is not rounded somehow
time = Math.round(time);

let hour = Math.floor(time / 3600);
let minute = Math.floor(time % 3600 / 60);
let second = time % 60;

let times = [minute, second];
if ( hour > 0 ) times = [hour, minute, second];
times = times.map( el => el < 10 ? (el+"").padStart(2, "0") : el);

return times.join(":");
var duration = moment.duration(time, 'seconds');
var formatted = duration.format("hh:mm:ss");
return formatted;
}
},
computed : {
Expand Down

0 comments on commit 2684e45

Please sign in to comment.