diff options
author | Sam Potts <sam@potts.es> | 2020-04-24 00:22:39 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 00:22:39 +1000 |
commit | 68137aa789b195b26d4306eaebc7fee2f8eb3374 (patch) | |
tree | 8c38683d043fdfbe8b1dcb385a446de4df7396a1 /src/js/utils/time.js | |
parent | dbe618c644a525b196466b7254274cc9bde76275 (diff) | |
parent | 2458eaa11b5c2805bcf1e5349ab900485bac325f (diff) | |
download | plyr-68137aa789b195b26d4306eaebc7fee2f8eb3374.tar.lz plyr-68137aa789b195b26d4306eaebc7fee2f8eb3374.tar.xz plyr-68137aa789b195b26d4306eaebc7fee2f8eb3374.zip |
Merge pull request #1770 from sampotts/css-variables
Allow customization via CSS Custom Properties
Diffstat (limited to 'src/js/utils/time.js')
-rw-r--r-- | src/js/utils/time.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/js/utils/time.js b/src/js/utils/time.js index 17228de5..31660c4a 100644 --- a/src/js/utils/time.js +++ b/src/js/utils/time.js @@ -11,25 +11,25 @@ export const getSeconds = value => Math.trunc(value % 60, 10); // Format time to UI friendly string export function formatTime(time = 0, displayHours = false, inverted = false) { - // Bail if the value isn't a number - if (!is.number(time)) { - return formatTime(undefined, displayHours, inverted); - } + // Bail if the value isn't a number + if (!is.number(time)) { + return formatTime(undefined, displayHours, inverted); + } - // Format time component to add leading zero - const format = value => `0${value}`.slice(-2); - // Breakdown to hours, mins, secs - let hours = getHours(time); - const mins = getMinutes(time); - const secs = getSeconds(time); + // Format time component to add leading zero + const format = value => `0${value}`.slice(-2); + // Breakdown to hours, mins, secs + let hours = getHours(time); + const mins = getMinutes(time); + const secs = getSeconds(time); - // Do we need to display hours? - if (displayHours || hours > 0) { - hours = `${hours}:`; - } else { - hours = ''; - } + // Do we need to display hours? + if (displayHours || hours > 0) { + hours = `${hours}:`; + } else { + hours = ''; + } - // Render - return `${inverted && time > 0 ? '-' : ''}${hours}${format(mins)}:${format(secs)}`; + // Render + return `${inverted && time > 0 ? '-' : ''}${hours}${format(mins)}:${format(secs)}`; } |