aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/utils/time.js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2020-04-28 22:20:49 +1000
committerGitHub <noreply@github.com>2020-04-28 22:20:49 +1000
commit99a26d65cf78851878841c5afc54830f1222ccb1 (patch)
tree6a2bf12ecfa2314725e6d8961ec9f6a986b5003b /src/js/utils/time.js
parent6aa21c1fae4a7b6dbcf1db1ee3b06f11d674869a (diff)
parent4915cf0120870db4a52b3be117efa22f8ca2bd3e (diff)
downloadplyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.lz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.tar.xz
plyr-99a26d65cf78851878841c5afc54830f1222ccb1.zip
Merge pull request #1796 from sampotts/develop
v3.6.0
Diffstat (limited to 'src/js/utils/time.js')
-rw-r--r--src/js/utils/time.js36
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)}`;
}