1 | const secondsToTime = require('./secondsToTime')
|
2 |
|
3 | module.exports = function prettyETA (seconds) {
|
4 | const time = secondsToTime(seconds)
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | const hoursStr = time.hours ? `${time.hours}h ` : ''
|
10 | const minutesVal = time.hours ? (`0${time.minutes}`).substr(-2) : time.minutes
|
11 | const minutesStr = minutesVal ? `${minutesVal}m` : ''
|
12 | const secondsVal = minutesVal ? (`0${time.seconds}`).substr(-2) : time.seconds
|
13 | const secondsStr = time.hours ? '' : (minutesVal ? ` ${secondsVal}s` : `${secondsVal}s`)
|
14 |
|
15 | return `${hoursStr}${minutesStr}${secondsStr}`
|
16 | }
|