Merge pull request #179 from Purple-Tentacle/master

I made some improvements and changed the image.
master
Gordon Williams 2020-04-02 08:11:25 +01:00 committed by GitHub
commit aa57655b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 8 deletions

View File

@ -27,7 +27,7 @@
{ "id": "daysl", { "id": "daysl",
"name": "Days left", "name": "Days left",
"icon": "app.png", "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.", "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": "", "tags": "",
"allow_emulator":false, "allow_emulator":false,

View File

@ -1 +1,2 @@
0.01: New Widget! 0.01: New Widget!
0.02: Improved calculation, new image for app

View File

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

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,17 +17,23 @@ 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);
const today = new Date(); 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(){ WIDGETS["daysl"]={area:"tl",width:40,draw:function(){
g.setFont("6x8", 1); g.setFont("6x8", 1);
g.drawString(diffDays,this.x+12,this.y+12); g.drawString(diffDays,this.x+12,this.y+12);
}}; }};