uppy/packages/@uppy/utils/src/prettyETA.js
Renée Kooi 2e257b7e55
Move utils files to @uppy/utils package.
And rewrite all the require calls.

```bash
git mv src/utils/* packages/@uppy/utils/src
sed -i 's/[./]*\/utils\//@uppy\/utils\/lib\//' src/**/*.js # transform (../)*utils → @uppy/utils
```
2018-06-14 16:31:19 +02:00

16 lines
701 B
JavaScript

const secondsToTime = require('./secondsToTime')
module.exports = function prettyETA (seconds) {
const time = secondsToTime(seconds)
// Only display hours and minutes if they are greater than 0 but always
// display minutes if hours is being displayed
// Display a leading zero if the there is a preceding unit: 1m 05s, but 5s
const hoursStr = time.hours ? time.hours + 'h ' : ''
const minutesVal = time.hours ? ('0' + time.minutes).substr(-2) : time.minutes
const minutesStr = minutesVal ? minutesVal + 'm ' : ''
const secondsVal = minutesVal ? ('0' + time.seconds).substr(-2) : time.seconds
const secondsStr = secondsVal + 's'
return `${hoursStr}${minutesStr}${secondsStr}`
}