Better way of determining 12 hour clock setting

master
deirdreobyrne 2022-06-07 02:11:53 +01:00 committed by GitHub
parent dd45d0e513
commit f0222b0195
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -28,16 +28,14 @@ function draw() {
w = date.getDay(); // d=1..31; w=0..6 w = date.getDay(); // d=1..31; w=0..6
const level = E.getBattery(); const level = E.getBattery();
const width = level + (level/2); const width = level + (level/2);
var settings = Object.assign({ var is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
"12hour": false,
}, require('Storage').readJSON("setting.json", true) || {});
g.reset(); g.reset();
g.clear(); g.clear();
g.setFontOpenSans(); g.setFontOpenSans();
g.setFontAlign(0, -1); g.setFontAlign(0, -1);
if (settings["12hour"]) { if (is12Hour) {
if (h > 12) h -= 12; if (h > 12) h -= 12;
if (h == 0) h = 12; if (h == 0) h = 12;
g.drawString(h + ":" + ("0"+m).substr(-2), g.getWidth() / 2, 30); g.drawString(h + ":" + ("0"+m).substr(-2), g.getWidth() / 2, 30);