From 2127f28ab7f0572314390ea5c77b03556fab9c72 Mon Sep 17 00:00:00 2001 From: lifeadventurer Date: Sun, 31 Dec 2023 21:04:08 +0800 Subject: [PATCH] fix: daysDiff function calculate error --- fortune_generator/js/fortune.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fortune_generator/js/fortune.js b/fortune_generator/js/fortune.js index 2e0732c..e93b213 100644 --- a/fortune_generator/js/fortune.js +++ b/fortune_generator/js/fortune.js @@ -8,7 +8,7 @@ fetch("https://api.ipify.org?format=json").then(response => { }).then(res => { ip = res.ip; -}).catch(err => { +}).catch(error => { if ('caches' in window) { caches.match('https://api.ipify.org?format=json').then(response => { if (response) { @@ -66,7 +66,7 @@ function daysDiff(eventIndex) { const endDate = new Date(`${special_events[eventIndex].year}-${special_events[eventIndex].month}-${special_events[eventIndex].date}`); // calculate the difference in milliseconds and convert it to days - const timeDiff = Math.floor((endDate - startDate) / (1000 * 60 * 60 * 24)); + const timeDiff = Math.ceil((endDate - startDate) / (1000 * 60 * 60 * 24)); return timeDiff; }