webamp/js/utils.js
2016-07-26 16:59:43 -07:00

27 lines
594 B
JavaScript

const getTimeObj = (time) => {
var minutes = Math.floor(time / 60);
var seconds = time % 60;
return {
minutesFirstDigit: Math.floor(minutes / 10),
minutesSecondDigit: Math.floor(minutes % 10),
secondsFirstDigit: Math.floor(seconds / 10),
secondsSecondDigit: Math.floor(seconds % 10)
};
};
const getTimeStr = (time) => {
const timeObj = getTimeObj(time);
return [
timeObj.minutesFirstDigit,
timeObj.minutesSecondDigit,
':',
timeObj.secondsFirstDigit,
timeObj.secondsSecondDigit
].join('');
};
module.exports = {
getTimeObj,
getTimeStr
};