Bug fix - use 12 / 24 hr clock based on user settings

master
Paul Cockrell 2020-04-03 09:16:22 +01:00
parent b135c097cf
commit 4f60a45022
3 changed files with 11 additions and 7 deletions

View File

@ -892,7 +892,7 @@
{ "id": "marioclock", { "id": "marioclock",
"name": "Mario Clock", "name": "Mario Clock",
"icon": "marioclock.png", "icon": "marioclock.png",
"version":"0.04", "version":"0.05",
"description": "Animated Mario clock, jumps to change the time!", "description": "Animated Mario clock, jumps to change the time!",
"tags": "clock,mario,retro", "tags": "clock,mario,retro",
"type": "clock", "type": "clock",

View File

@ -2,3 +2,4 @@
0.02: Fix day of the week and add padding 0.02: Fix day of the week and add padding
0.03: use short date format from locale, take timeout from settings 0.03: use short date format from locale, take timeout from settings
0.04: modify date to display to be more at the original idea but still localized 0.04: modify date to display to be more at the original idea but still localized
0.05: use 12/24 hour clock from settings

View File

@ -1,14 +1,15 @@
/********************************** /**********************************
BangleJS MARIO CLOCK V0.1.0 BangleJS MARIO CLOCK
+ Based on Espruino Mario Clock V3 https://github.com/paulcockrell/espruino-mario-clock + Based on Espruino Mario Clock V3 https://github.com/paulcockrell/espruino-mario-clock
+ Converting images to 1bit BMP: Image > Mode > Indexed and tick the "Use black and white (1-bit) palette", Then export as BMP. + Converting images to 1bit BMP: Image > Mode > Indexed and tick the "Use black and white (1-bit) palette", Then export as BMP.
+ Online Image convertor: https://www.espruino.com/Image+Converter + Online Image convertor: https://www.espruino.com/Image+Converter
**********************************/ **********************************/
var locale = require("locale"); const locale = require("locale");
const storage = require('Storage'); const storage = require('Storage');
const settings = (storage.readJSON('setting.json',1) || {}); const settings = (storage.readJSON('setting.json',1) || {});
const timeout = settings.timeout || 10; const timeout = settings.timeout || 10;
const is12Hour = settings["12hour"] || false;
// Screen dimensions // Screen dimensions
let W, H; let W, H;
@ -273,7 +274,8 @@ function drawTime() {
drawBrick(42, 25); drawBrick(42, 25);
const t = new Date(); const t = new Date();
const hours = ("0" + t.getHours()).substr(-2); const h = t.getHours();
const hours = ("0" + ((is12Hour && h > 12) ? h - 12 : h)).substr(-2);
const mins = ("0" + t.getMinutes()).substr(-2); const mins = ("0" + t.getMinutes()).substr(-2);
g.setFont("6x8"); g.setFont("6x8");
@ -374,8 +376,9 @@ function init() {
Bangle.setLCDPower(true); Bangle.setLCDPower(true);
} }
}); });
startTimers();
} }
// Initialise! // Initialise!
init(); init();
startTimers();