Browse Source

Always include minutes in bookmark title.

E.g. 3-6 is not descriptive enough. Better to write 0:03–0:06.
tags/v0.1.0
Gerben 4 years ago
parent
commit
b7330facb7
1 changed files with 4 additions and 6 deletions
  1. +4
    -6
      app/create-bookmarks/background.js

+ 4
- 6
app/create-bookmarks/background.js View File

@@ -1,16 +1,14 @@
import { makeRemotelyCallable } from 'webextension-rpc'; import { makeRemotelyCallable } from 'webextension-rpc';


// Format time as S, or M:SS, or H:MM:SS, depending on which would be needed to express maxSeconds.
// E.g. secondsToString(12) === '12', but secondsToString(12, 3600) === '0:00:12'.
// Format time as M:SS, or H:MM:SS, depending on which would be needed to express maxSeconds.
// E.g. secondsToString(12) === '0:12', but secondsToString(12, 3600) === '0:00:12'.
function secondsToString(seconds, maxSeconds) { function secondsToString(seconds, maxSeconds) {
let s = `${Math.round(seconds % 60)}`; let s = `${Math.round(seconds % 60)}`;
let m = ''; let m = '';
let h = ''; let h = '';
const minutes = Math.floor(seconds / 60); const minutes = Math.floor(seconds / 60);
if (minutes || maxSeconds >= 60) {
m = `${minutes % 60}:`;
if (!/^\d\d/.test(s)) s = '0' + s;
}
m = `${minutes % 60}:`;
if (!/^\d\d/.test(s)) s = '0' + s;
if (seconds >= 60 * 60 || maxSeconds >= 60 * 60) { if (seconds >= 60 * 60 || maxSeconds >= 60 * 60) {
h = `${Math.floor(minutes / 60)}:`; h = `${Math.floor(minutes / 60)}:`;
if (m.length <= 2) m = '0' + m; if (m.length <= 2) m = '0' + m;


Loading…
Cancel
Save