fix #182
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 19s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 19s
This commit is contained in:
parent
78a84faca4
commit
1bc77efb2a
1 changed files with 10 additions and 7 deletions
|
@ -53,19 +53,22 @@ 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]) => {
|
||||
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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue