From c1feba9513b4c011d35792886e8ecdc9f5bc9f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20T=C3=B6lle?= Date: Sun, 2 Apr 2023 14:49:29 +0200 Subject: [PATCH] fix: last update timer on listory page always showed "Just Now" --- layouts/partials/extend_head.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/partials/extend_head.html b/layouts/partials/extend_head.html index 03e30cd..577e910 100644 --- a/layouts/partials/extend_head.html +++ b/layouts/partials/extend_head.html @@ -20,16 +20,16 @@ return; } - const diffMs = date - new Date(); + const diffMs = new Date() - date; const hoursSince = diffMs / 1000 / 60 / 60; const daysSince = hoursSince / 24; let formatted = ""; if (daysSince > 1) { - formatted = formatter.format(daysSince, "days"); + formatted = formatter.format(-Math.round(daysSince), "days"); } else if (hoursSince > 1) { - formatted = formatter.format(daysSince, "hours"); + formatted = formatter.format(-Math.round(hoursSince), "hours"); } else { formatted = "Just Now!"; }