You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
consul/ui-v2/app/helpers/format-time.js

30 lines
693 B

import { helper } from '@ember/component/helper';
export default helper(function formatTime([params], hash) {
let day, hour, minute, seconds;
seconds = Math.floor(params / 1000);
minute = Math.floor(seconds / 60);
seconds = seconds % 60;
hour = Math.floor(minute / 60);
minute = minute % 60;
day = Math.floor(hour / 24);
hour = hour % 24;
const time = {
day: day,
hour: hour,
minute: minute,
seconds: seconds,
};
switch (true) {
case time.day !== 0:
return time.day + 'd';
case time.hour !== 0:
return time.hour + 'h';
case time.minute !== 0:
return time.minute + 'm';
default:
return time.seconds + 's';
}
});