show elapsed time

This commit is contained in:
Cory Sanin 2025-01-14 01:52:31 -05:00
parent c3554afde9
commit 40f04162d0
2 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,17 @@ function notStupidParseInt(v: string | undefined): number {
return v === undefined ? NaN : parseInt(v);
}
function timeElapsed(date1: Date, date2: Date) {
if (!date2 || ! date1) {
return '-';
}
const ms = Math.abs(date2.getTime() - date1.getTime());
const seconds = Math.floor(ms / 1000) % 60;
const minutes = Math.floor(ms / (1000 * 60)) % 60;
const hours = Math.floor(ms / (1000 * 60 * 60));
return `${hours}:${minutes}:${seconds}`;
}
class Web {
private _webserver: http.Server | null = null;
private db: DB;
@ -57,7 +68,8 @@ class Web {
titlesuffix: 'Dashboard',
description: 'PKGBUILD central'
},
builds
builds,
timeElapsed
});
}
catch (err) {

View File

@ -22,7 +22,7 @@
<td><a href="/build/<%= build.id %>"><%= build.repo %></a></td>
<td><%= build.distro %></td>
<td class="to-local-time"><%= build.startTime %></td>
<td>TODO</td>
<td><%= timeElapsed(build.startTime, build.endTime) %></td>
<td><%= build.status %></td>
</tr>
<% }) %>