mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-29 04:50:05 +00:00
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 ```
16 lines
701 B
JavaScript
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}`
|
|
}
|