|
1 | 1 | <script setup lang="tsx"> |
2 | 2 | import {h, ref, Ref} from "vue"; |
| 3 | +import {differenceInSeconds} from "date-fns"; |
3 | 4 |
|
4 | 5 | import {getJson} from "../../utils/requests"; |
5 | 6 | import {STATUS_DATA_URL} from "../../urls"; |
6 | 7 | import {withLoading} from "../../utils/loading"; |
7 | | -import {formatISODate, formatSecondsAsDuration} from "../../utils/formatting"; |
| 8 | +import { |
| 9 | + formatISODate, |
| 10 | + formatSecondsAsDuration, |
| 11 | + parseDateIsoStringOrNull, |
| 12 | +} from "../../utils/formatting"; |
8 | 13 | import {useExpandedStore} from "../../utils/expansion"; |
9 | 14 | import { |
10 | 15 | BenchmarkRequest, |
@@ -110,14 +115,22 @@ function ExpectedCurrentRequestCompletion() { |
110 | 115 | if (!req) return ""; |
111 | 116 | if (!req.endEstimated) return ""; |
112 | 117 | if (!req.completedAt) return ""; |
113 | | - const formattedDate = formatISODate(req.completedAt); |
| 118 | + const estimatedCompleted = parseDateIsoStringOrNull(req.completedAt); |
| 119 | + if (!estimatedCompleted) { |
| 120 | + return null; |
| 121 | + } |
| 122 | +
|
| 123 | + const now = new Date(); |
| 124 | + const diffSeconds = differenceInSeconds(estimatedCompleted, now); |
| 125 | + const prettyDisplay = formatSecondsAsDuration(diffSeconds); |
| 126 | +
|
114 | 127 | return ( |
115 | 128 | <span> |
116 | 129 | Current Benchmark for{" "} |
117 | 130 | <strong> |
118 | 131 | <CommitSha tag={req.tag}></CommitSha> |
119 | 132 | </strong>{" "} |
120 | | - expected to end at {formattedDate}{" "} |
| 133 | + expected to end in approximately {prettyDisplay} |
121 | 134 | </span> |
122 | 135 | ); |
123 | 136 | } |
|
0 commit comments