From e68ec16a348326b2fb93381540a27750d1c2b6d1 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 2 Mar 2021 15:03:58 +0100 Subject: [PATCH] web: improve display of notification age --- web/src/elements/notifications/NotificationDrawer.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web/src/elements/notifications/NotificationDrawer.ts b/web/src/elements/notifications/NotificationDrawer.ts index f366ec440..8b8e77ae8 100644 --- a/web/src/elements/notifications/NotificationDrawer.ts +++ b/web/src/elements/notifications/NotificationDrawer.ts @@ -40,9 +40,7 @@ export class NotificationDrawer extends LitElement { } renderItem(item: Notification): TemplateResult { - const delta = Date.now() - (parseInt(item.created, 10) * 1000); - // TODO: more flexible display, minutes and seconds - const age = `${Math.round(delta / 1000 / 3600)} Hours ago`; + const created = new Date(parseInt(item.created, 10) * 1000); let level = ""; switch (item.severity) { case "notice": @@ -76,7 +74,7 @@ export class NotificationDrawer extends LitElement {

${item.body}

- ${age} + ${created.toLocaleString()} `; }