calc to end of target day , default year 2020
parent
143e3da6f6
commit
40be3f0a27
|
|
@ -4,12 +4,12 @@ let settings;
|
|||
function updateSettings() {
|
||||
storage.write('daysleft.json', settings);
|
||||
}
|
||||
|
||||
|
||||
function resetSettings() {
|
||||
settings = {
|
||||
day : 17,
|
||||
month : 6,
|
||||
year: 1981
|
||||
year: 2020
|
||||
};
|
||||
updateSettings();
|
||||
}
|
||||
|
|
@ -17,12 +17,12 @@ function updateSettings() {
|
|||
settings = storage.readJSON('daysleft.json',1);
|
||||
if (!settings) resetSettings();
|
||||
|
||||
var dd = settings.day+1,
|
||||
mm = settings.month-1,
|
||||
var dd = settings.day,
|
||||
mm = settings.month-1, //month is zero-based
|
||||
yy = settings.year;
|
||||
|
||||
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 diffDays = Math.round(Math.abs((targetDate - today) / oneDay));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue