fix negative countdown

master
lub 4 years ago
parent 65ca06a1d1
commit 1c5d909576

@ -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

Loading…
Cancel
Save