fix: daysDiff function calculate error

This commit is contained in:
lifeadventurer
2023-12-31 21:04:08 +08:00
parent 72e2d6d1b5
commit 2127f28ab7

View File

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