1
0
Fork 0

Merge pull request #3451 from paul-arg/elapsed_t

elapsed_t: add option to set clock as default and handle DST in day/month/year mode
master
Rob Pilling 2024-06-16 16:20:07 +01:00 committed by GitHub
commit 20810b4403
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 4 deletions

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Handle AM/PM time in the "set target" menu. Add yesterday/today/tomorrow when showing target date to improve readability.
0.02: Handle AM/PM time in the "set target" menu. Add yesterday/today/tomorrow when showing target date to improve readability.
0.03: Add option to set clock as default, handle DST in day/month/year mode

View File

@ -57,7 +57,7 @@ function writeSettings() {
let inMenu = false;
Bangle.on('touch', function (zone, e) {
if (!inMenu) {
if (!inMenu && e.y > 24) {
if (drawTimeout) clearTimeout(drawTimeout);
E.showMenu(menu);
inMenu = true;
@ -206,9 +206,25 @@ var menu = {
setTarget(false);
updateQueueMillis(settings.displaySeconds);
draw();
},
'Set clock as default': function () {
setClockAsDefault();
E.showAlert("Elapsed Time was set as default").then(function() {
E.showMenu();
inMenu = false;
Bangle.setUI("clock");
draw();
});
}
};
function setClockAsDefault(){
let storage = require('Storage');
let settings = storage.readJSON('setting.json',true)||{clock:null};
settings.clock = "elapsed_t.app.js";
storage.writeJSON('setting.json', settings);
}
function setTarget(set) {
if (set) {
target = new Date(
@ -276,6 +292,10 @@ function updateQueueMillis(displaySeconds) {
}
Bangle.on('lock', function (on, reason) {
if (inMenu) { // if already in a menu, nothing to do
return;
}
if (on) { // screen is locked
temp_displaySeconds = false;
updateQueueMillis(false);
@ -326,7 +346,7 @@ function diffToTarget() {
diff.M = end.getMonth() - start.getMonth();
diff.D = end.getDate() - start.getDate();
diff.hh = end.getHours() - start.getHours();
diff.mm = end.getMinutes() - start.getMinutes();
diff.mm = end.getMinutes() - start.getMinutes() + end.getTimezoneOffset() - start.getTimezoneOffset();
diff.ss = end.getSeconds() - start.getSeconds();
// Adjust negative differences

View File

@ -3,7 +3,7 @@
"name": "Elapsed Time Clock",
"shortName": "Elapsed Time",
"type": "clock",
"version":"0.02",
"version":"0.03",
"description": "A clock that calculates the time difference between now and any given target date.",
"tags": "clock,tool",
"supports": ["BANGLEJS2"],