diff --git a/src/utils/time.ts b/src/utils/time.ts index 33f6d8c..86a6f0a 100644 --- a/src/utils/time.ts +++ b/src/utils/time.ts @@ -53,18 +53,21 @@ export const strToSeconds = (time: string) => { RegExpFlags.Global | RegExpFlags.Insensitive, ); - const data = Object.assign({}, regex.exec(time)?.groups); - - if (Object.keys(data).length === 0) { + const data = Array.from(time.matchAll(regex)); + if (data.length === 0) { // Regex returned an invalid time return -1; } let res = 0; - Object.entries(data).forEach(([key, value]) => { - if (value) { - res += +value * TimeSecond[key as keyof typeof TimeSecond]; - } + data.forEach((match) => { + console.log(match.groups); + + Object.entries(match.groups!).forEach(([key, value]) => { + if (value) { + res += +value * TimeSecond[key as keyof typeof TimeSecond]; + } + }); }); return res;