Merge pull request #179 from Purple-Tentacle/master
I made some improvements and changed the image.master
commit
aa57655b79
|
|
@ -27,7 +27,7 @@
|
|||
{ "id": "daysl",
|
||||
"name": "Days left",
|
||||
"icon": "app.png",
|
||||
"version":"0.01",
|
||||
"version":"0.02",
|
||||
"description": "Shows you the days left until a certain date. Date can be set with a settings app and is written to a file.",
|
||||
"tags": "",
|
||||
"allow_emulator":false,
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
0.01: New Widget!
|
||||
0.02: Improved calculation, new image for app
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwMB//D/4CgwHDFYPDgICBAoQCB/4CKADmAAgcBIARCCAqQAXF/4v24CtDgYFR"))
|
||||
require("heatshrink").decompress(atob("mEwgmIAH4A/AH4A/AEEAAAgGOC/4XLAgoGIDgYXTwEIBY4JEAw8YCIOAEY4+EAwwTCL44XNO5IX/C6i6LC8YABa5AXOF67vIwA5DAw5GDMhg7HjAXWIwQLFZIoGNC/4XKAH4A/AH4A/ADoA="))
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 287 B After Width: | Height: | Size: 468 B |
|
|
@ -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,17 +17,23 @@ 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 today = new Date();
|
||||
const diffDays = Math.round(Math.abs((targetDate - today) / oneDay));
|
||||
|
||||
//create date object with today, but 00:00:00
|
||||
const currentYear = today.getFullYear();
|
||||
const currentMonth = today.getMonth();
|
||||
const currentDay = today.getDate();
|
||||
const todayMorning = new Date (currentYear, currentMonth, currentDay, 0, 0, 0);
|
||||
|
||||
const diffDays = (targetDate - todayMorning) / oneDay;
|
||||
|
||||
WIDGETS["daysl"]={area:"tl",width:40,draw:function(){
|
||||
|
||||
g.setFont("6x8", 1);
|
||||
g.drawString(diffDays,this.x+12,this.y+12);
|
||||
}};
|
||||
Loading…
Reference in New Issue