calc to end of target day , default year 2020
parent
143e3da6f6
commit
40be3f0a27
|
|
@ -4,12 +4,12 @@ let settings;
|
||||||
function updateSettings() {
|
function updateSettings() {
|
||||||
storage.write('daysleft.json', settings);
|
storage.write('daysleft.json', settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetSettings() {
|
function resetSettings() {
|
||||||
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));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue