From 48868f01fe03a2e87ac9f872fb493a00303ecc18 Mon Sep 17 00:00:00 2001 From: sadan4 <117494111+sadan4@users.noreply.github.com> Date: Mon, 17 Mar 2025 22:49:52 -0400 Subject: [PATCH] MessageLatency: Fix off by one error on some deltas (#3297) --- src/plugins/messageLatency/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/messageLatency/index.tsx b/src/plugins/messageLatency/index.tsx index f0d5f960..460b95a8 100644 --- a/src/plugins/messageLatency/index.tsx +++ b/src/plugins/messageLatency/index.tsx @@ -63,11 +63,11 @@ export default definePlugin({ stringDelta(delta: number, showMillis: boolean) { const diff: Diff = { - days: Math.round(delta / (60 * 60 * 24 * 1000)), - hours: Math.round((delta / (60 * 60 * 1000)) % 24), - minutes: Math.round((delta / (60 * 1000)) % 60), - seconds: Math.round(delta / 1000 % 60), - milliseconds: Math.round(delta % 1000) + days: Math.floor(delta / (60 * 60 * 24 * 1000)), + hours: Math.floor((delta / (60 * 60 * 1000)) % 24), + minutes: Math.floor((delta / (60 * 1000)) % 60), + seconds: Math.floor(delta / 1000 % 60), + milliseconds: Math.floor(delta % 1000) }; const str = (k: DiffKey) => diff[k] > 0 ? `${diff[k]} ${diff[k] > 1 ? k : k.substring(0, k.length - 1)}` : null;