chore: merge dev to main #181

Merged
Anri merged 40 commits from dev into main 2024-09-27 20:49:36 +02:00
Showing only changes of commit 1bc77efb2a - Show all commits

View file

@ -53,19 +53,22 @@ export const strToSeconds = (time: string) => {
RegExpFlags.Global | RegExpFlags.Insensitive, RegExpFlags.Global | RegExpFlags.Insensitive,
); );
const data = Object.assign({}, regex.exec(time)?.groups); const data = Array.from(time.matchAll(regex));
if (data.length === 0) {
if (Object.keys(data).length === 0) {
// Regex returned an invalid time // Regex returned an invalid time
return -1; return -1;
} }
let res = 0; let res = 0;
Object.entries(data).forEach(([key, value]) => { data.forEach((match) => {
console.log(match.groups);
Object.entries(match.groups!).forEach(([key, value]) => {
if (value) { if (value) {
res += +value * TimeSecond[key as keyof typeof TimeSecond]; res += +value * TimeSecond[key as keyof typeof TimeSecond];
} }
}); });
});
return res; return res;
}; };