diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-07-27 15:44:29 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-07-27 15:44:29 +0200 |
| commit | 2aad507650fa3263ef81be759ab0531b43e5b7cc (patch) | |
| tree | b8299f962ef0e3342cb8978f5e0a4f57a8ee1b30 /animism-align/frontend/app/utils/index.js | |
| parent | eee3193ecf604eaed30505128b2a1f7bb875d44a (diff) | |
annotation form for curtain events. refactor utilities
Diffstat (limited to 'animism-align/frontend/app/utils/index.js')
| -rw-r--r-- | animism-align/frontend/app/utils/index.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/animism-align/frontend/app/utils/index.js b/animism-align/frontend/app/utils/index.js index c2dd464..273c0ef 100644 --- a/animism-align/frontend/app/utils/index.js +++ b/animism-align/frontend/app/utils/index.js @@ -70,6 +70,17 @@ export const timestamp = (n = 0, fps = 1, ms = false) => { return (n % 60) + ':' + s } +export const timestampToSeconds = time_str => { + const time_str_parts = time_str.trim().split(":").map(s => parseFloat(s)) + if (time_str_parts.length === 3) { + return (time_str_parts[0] * 60 + time_str_parts[1]) * 60 + time_str_parts[2] + } + if (time_str_parts.length === 2) { + return time_str_parts[0] * 60 + time_str_parts[1] + } + return time_str_parts[0] +} + export const percent = n => (n * 100).toFixed(1) + '%' export const px = (n, w) => Math.round(n * w) + 'px' |
