Compare commits

..

No commits in common. "8f33dd8ea4907d5f20ca55e5a4c6b82ad9604fa6" and "1bc77efb2aecb41c2169605891d5c568e81b3052" have entirely different histories.

2 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,4 @@
import { showDate, strToSeconds } from "../../utils/time";
import { showDate } from "../../utils/time";
describe("Date with correct timezone", () => {
const map = new Map([["u_time_at", "@"]]);
@ -31,18 +31,20 @@ describe("Date with correct timezone", () => {
}
});
describe("String time to seconds", () => {
/* describe("String time to seconds", () => {
{
const name = "10m30";
test(name, () => {
expect(strToSeconds(name)).toBe(630);
});
}
}); */
/* describe("Time delta", () => {
{
// todo: see https://git.mylloon.fr/ConfrerieDuKassoulait/Botanique/issues/183
const name = "12h30";
test(name, () => {
/* expect(strToSeconds(name)).toBe(45000); */
const name = 1312;
test(name.toString(), () => {
expect(timeDeltaToString(name)).toBe("0 secs");
});
}
});
}); */

View file

@ -61,6 +61,8 @@ export const strToSeconds = (time: string) => {
let res = 0;
data.forEach((match) => {
console.log(match.groups);
Object.entries(match.groups!).forEach(([key, value]) => {
if (value) {
res += +value * TimeSecond[key as keyof typeof TimeSecond];