(est: number)
| 38 | ): [number | undefined, string] => { |
| 39 | const sinceStart = dayjs().diff(startedAt); |
| 40 | const secondsLeft = (est: number) => { |
| 41 | const max = Math.max( |
| 42 | Math.ceil(dayjs.duration((1 - sinceStart / est) * est).asSeconds()), |
| 43 | 0, |
| 44 | ); |
| 45 | return Number.isNaN(max) ? 0 : max; |
| 46 | }; |
| 47 | |
| 48 | // Under-promise, over-deliver with the 95th percentile estimate. |
| 49 | const highGuess = secondsLeft(p95); |