Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 22x 711x 711x 5x 706x 706x 706x | const UNIT_IN_SECONDS = {
s: 1,
m: 60,
h: 3600,
d: 86400,
} as const;
export function parseDurationToSeconds(duration: string): number {
const match = /^(\d+)(s|m|h|d)$/.exec(duration);
if (!match) {
throw new Error(`Invalid duration format: ${duration}`);
}
const amount = Number(match[1]);
const unit = match[2] as 's' | 'm' | 'h' | 'd';
return amount * UNIT_IN_SECONDS[unit];
}
|