calc to end of target day , default year 2020

master
Christian Hemker 2020-04-01 20:18:50 +02:00
parent 143e3da6f6
commit 40be3f0a27
1 changed files with 5 additions and 5 deletions

View File

@ -9,7 +9,7 @@ function updateSettings() {
settings = { settings = {
day : 17, day : 17,
month : 6, month : 6,
year: 1981 year: 2020
}; };
updateSettings(); updateSettings();
} }
@ -17,12 +17,12 @@ function updateSettings() {
settings = storage.readJSON('daysleft.json',1); settings = storage.readJSON('daysleft.json',1);
if (!settings) resetSettings(); if (!settings) resetSettings();
var dd = settings.day+1, var dd = settings.day,
mm = settings.month-1, mm = settings.month-1, //month is zero-based
yy = settings.year; yy = settings.year;
const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds const oneDay = 24 * 60 * 60 * 1000; // hours*minutes*seconds*milliseconds
const targetDate = new Date(yy, mm, dd); const targetDate = new Date(yy, mm, dd, 23, 59, 59);
const today = new Date(); const today = new Date();
const diffDays = Math.round(Math.abs((targetDate - today) / oneDay)); const diffDays = Math.round(Math.abs((targetDate - today) / oneDay));