correct parsing for timestamp-links in current video

This commit is contained in:
robertkleinschuster
2023-05-25 20:43:11 +02:00
committed by robertkleinschuster
parent 3dfdf8806f
commit 66f3584895
4 changed files with 56 additions and 33 deletions

View File

@@ -6,3 +6,24 @@ export const isEmail = input => {
);
return result;
};
export const parseTimeParam = time => {
let start = 0;
if (/^[\d]*$/g.test(time)) {
start = time;
} else {
const hours = /([\d]*)h/gi.exec(time)?.[1];
const minutes = /([\d]*)m/gi.exec(time)?.[1];
const seconds = /([\d]*)s/gi.exec(time)?.[1];
if (hours) {
start += parseInt(hours) * 60 * 60;
}
if (minutes) {
start += parseInt(minutes) * 60;
}
if (seconds) {
start += parseInt(seconds);
}
}
return start;
};