(value)
| 67 | .slice(0, 80) || "job" |
| 68 | } |
| 69 | |
| 70 | function parseDuration(value) { |
| 71 | const input = String(value || "").trim() |
| 72 | if (input === "0") return 0 |
| 73 | const match = input.match(/^(\d+)\s*(ms|s|sec|secs|second|seconds|m|min|mins|minute|minutes|h|hr|hrs|hour|hours|d|day|days)$/i) |
| 74 | if (!match) return null |
| 75 | const amount = Number.parseInt(match[1], 10) |
| 76 | const unit = match[2].toLowerCase() |
| 77 | if (!Number.isFinite(amount) || amount < 0) return null |
| 78 | if (unit === "ms") return amount |
| 79 | if (unit.startsWith("s")) return amount * 1000 |
| 80 | if (unit.startsWith("m")) return amount * 60_000 |
| 81 | if (unit.startsWith("h")) return amount * 3_600_000 |
| 82 | if (unit.startsWith("d")) return amount * 86_400_000 |
| 83 | return null |
| 84 | } |
| 85 | |
| 86 | function durationToText(ms) { |
no outgoing calls
no test coverage detected