MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / parseDuration

Function parseDuration

src/core/duration.ts:13–22  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

11 */
12
13export function parseDuration(s: string): number | null {
14 const re = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/
15 const m = re.exec(s.trim())
16 if (!m) return null
17 const h = Number(m[1] ?? 0)
18 const min = Number(m[2] ?? 0)
19 const sec = Number(m[3] ?? 0)
20 if (h === 0 && min === 0 && sec === 0) return null
21 return (h * 3600 + min * 60 + sec) * 1000
22}

Callers 4

mainFunction · 0.85
createPumpFunction · 0.85
computeNextRunFunction · 0.85
duration.spec.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected