diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-08-26 22:28:13 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-08-26 22:28:13 +0200 |
| commit | fe515fa4bc940183ba9253e67461c1f009a5d94b (patch) | |
| tree | 040f816ac41d2ce4f13b4c653929bb70fc9a2cfe /animism-align/frontend/app/utils/index.js | |
| parent | 14c8fd88b99dbab731c50f7285f7d799f17f86ff (diff) | |
times and stuff on the section nav
Diffstat (limited to 'animism-align/frontend/app/utils/index.js')
| -rw-r--r-- | animism-align/frontend/app/utils/index.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/animism-align/frontend/app/utils/index.js b/animism-align/frontend/app/utils/index.js index 7f9100c..0f5a1dd 100644 --- a/animism-align/frontend/app/utils/index.js +++ b/animism-align/frontend/app/utils/index.js @@ -53,9 +53,9 @@ export const capitalize = s => s.split(' ').map(capitalizeWord).join(' ') export const capitalizeWord = s => s.substr(0, 1).toUpperCase() + s.substr(1) export const padSeconds = n => n < 10 ? '0' + n : n -export const timestamp = (n = 0, fps = 1, ms = false) => { +export const timestamp = (n = 0, fps = 1, ms = false, h_label = ':', m_label = ':', s_label = '') => { if (n < 0) { - return '0:00' + return '0' + m_label + '00' + s_label } let s = '' n /= fps @@ -67,11 +67,13 @@ export const timestamp = (n = 0, fps = 1, ms = false) => { s = padSeconds(n % 60) + s n = Math.floor(n / 60) if (n > 60) { - return Math.floor(n / 60) + ':' + padSeconds(n % 60) + ':' + s + return Math.floor(n / 60) + h_label + padSeconds(n % 60) + m_label + s + s_label } - return (n % 60) + ':' + s + return (n % 60) + m_label + s + s_label } +export const timestampHMS = n => timestamp(n, 1, false, 'h', 'm', 's') + export const timestampToSeconds = time_str => { const time_str_parts = (time_str || "").trim().split(":").map(s => parseFloat(s)) if (time_str_parts.length === 3) { @@ -93,6 +95,8 @@ export const mod = (n, m) => n - (m * Math.floor(n / m)) export const angle = (x1, y1, x2, y2) => Math.atan2(y2 - y1, x2 - x1) export const floatLT = (a,b) => ((a*10|0) < (b*10|0)) export const floatLTE = (a,b) => ((a*10|0) === (b*10|0) || floatLT(a,b)) +export const floatGT = (a,b) => ((a*10|0) > (b*10|0)) +export const floatGTE = (a,b) => ((a*10|0) === (b*10|0) || floatGT(a,b)) export const floatInRange = (a,b,c) => floatLTE(a, b) && floatLT(b, c) export const simpleArraysEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b) |
