barclock: use ClockFace.is12Hour instead of reading the setting
parent
f7efc338f1
commit
33d25e4b07
|
|
@ -8,3 +8,4 @@
|
||||||
0.08: Use theme colors, Layout library
|
0.08: Use theme colors, Layout library
|
||||||
0.09: Fix time/date disappearing after fullscreen notification
|
0.09: Fix time/date disappearing after fullscreen notification
|
||||||
0.10: Use ClockFace library
|
0.10: Use ClockFace library
|
||||||
|
0.11: Use ClockFace.is12Hour
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
* A simple digital clock showing seconds as a bar
|
* A simple digital clock showing seconds as a bar
|
||||||
**/
|
**/
|
||||||
// Check settings for what type our clock should be
|
// Check settings for what type our clock should be
|
||||||
const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"];
|
|
||||||
let locale = require("locale");
|
let locale = require("locale");
|
||||||
{ // add some more info to locale
|
{ // add some more info to locale
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
|
@ -25,7 +24,7 @@ function renderBar(l) {
|
||||||
|
|
||||||
|
|
||||||
function timeText(date) {
|
function timeText(date) {
|
||||||
if (!is12Hour) {
|
if (!clock.is12Hour) {
|
||||||
return locale.time(date, true);
|
return locale.time(date, true);
|
||||||
}
|
}
|
||||||
const date12 = new Date(date.getTime());
|
const date12 = new Date(date.getTime());
|
||||||
|
|
@ -38,7 +37,7 @@ function timeText(date) {
|
||||||
return locale.time(date12, true);
|
return locale.time(date12, true);
|
||||||
}
|
}
|
||||||
function ampmText(date) {
|
function ampmText(date) {
|
||||||
return (is12Hour && locale.hasMeridian)? locale.meridian(date) : "";
|
return (clock.is12Hour && locale.hasMeridian) ? locale.meridian(date) : "";
|
||||||
}
|
}
|
||||||
function dateText(date) {
|
function dateText(date) {
|
||||||
const dayName = locale.dow(date, true),
|
const dayName = locale.dow(date, true),
|
||||||
|
|
@ -69,7 +68,7 @@ const ClockFace = require("ClockFace"),
|
||||||
}, {lazy: true});
|
}, {lazy: true});
|
||||||
// adjustments based on screen size and whether we display am/pm
|
// adjustments based on screen size and whether we display am/pm
|
||||||
let thickness; // bar thickness, same as time font "pixel block" size
|
let thickness; // bar thickness, same as time font "pixel block" size
|
||||||
if (is12Hour) {
|
if (this.is12Hour) {
|
||||||
// Maximum font size = (<screen width> - <ampm: 2chars * (2*6)px>) / (5chars * 6px)
|
// Maximum font size = (<screen width> - <ampm: 2chars * (2*6)px>) / (5chars * 6px)
|
||||||
thickness = Math.floor((Bangle.appRect.w-24)/(5*6));
|
thickness = Math.floor((Bangle.appRect.w-24)/(5*6));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "barclock",
|
"id": "barclock",
|
||||||
"name": "Bar Clock",
|
"name": "Bar Clock",
|
||||||
"version": "0.10",
|
"version": "0.11",
|
||||||
"description": "A simple digital clock showing seconds as a bar",
|
"description": "A simple digital clock showing seconds as a bar",
|
||||||
"icon": "clock-bar.png",
|
"icon": "clock-bar.png",
|
||||||
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],
|
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue