From 1c5d90957688a4dc1b71e67b08e4ef2b634c8a64 Mon Sep 17 00:00:00 2001 From: lub Date: Wed, 14 Oct 2020 21:18:26 +0200 Subject: [PATCH] fix negative countdown --- main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.js b/main.js index e6eb6d7..db2fda6 100644 --- a/main.js +++ b/main.js @@ -10,10 +10,10 @@ const update_countdown = () => { const diff = target - now; const timeleft = {}; - timeleft.days = Math.floor(diff/day); - timeleft.hours = Math.floor(diff%day/hour); - timeleft.minutes = Math.floor(diff%day%hour/minute); - timeleft.seconds = Math.floor(diff%day%hour%minute/second); + timeleft.days = Math.trunc(diff/day); + timeleft.hours = Math.trunc(diff%day/hour); + timeleft.minutes = Math.trunc(diff%day%hour/minute); + timeleft.seconds = Math.trunc(diff%day%hour%minute/second); Object.keys(timeleft).forEach((unit) => { // retrieve value, cast it to string and optionally pad it with a leading 0