From 40f04162d05a1299f3c9869f46e08346217d8d02 Mon Sep 17 00:00:00 2001 From: Cory Sanin Date: Tue, 14 Jan 2025 01:52:31 -0500 Subject: [PATCH] show elapsed time --- src/Web.ts | 14 +++++++++++++- views/index.ejs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Web.ts b/src/Web.ts index 5ce4442..02fec01 100644 --- a/src/Web.ts +++ b/src/Web.ts @@ -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) { diff --git a/views/index.ejs b/views/index.ejs index a0b274d..4b0510b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -22,7 +22,7 @@ <%= build.repo %> <%= build.distro %> <%= build.startTime %> - TODO + <%= timeElapsed(build.startTime, build.endTime) %> <%= build.status %> <% }) %>