fix: last update timer on listory page always showed "Just Now"

This commit is contained in:
Julian Tölle 2023-04-02 14:49:29 +02:00
parent a87369c085
commit c1feba9513

View file

@ -20,16 +20,16 @@
return; return;
} }
const diffMs = date - new Date(); const diffMs = new Date() - date;
const hoursSince = diffMs / 1000 / 60 / 60; const hoursSince = diffMs / 1000 / 60 / 60;
const daysSince = hoursSince / 24; const daysSince = hoursSince / 24;
let formatted = ""; let formatted = "";
if (daysSince > 1) { if (daysSince > 1) {
formatted = formatter.format(daysSince, "days"); formatted = formatter.format(-Math.round(daysSince), "days");
} else if (hoursSince > 1) { } else if (hoursSince > 1) {
formatted = formatter.format(daysSince, "hours"); formatted = formatter.format(-Math.round(hoursSince), "hours");
} else { } else {
formatted = "Just Now!"; formatted = "Just Now!";
} }