mirror of https://github.com/espruino/BangleApps
parent
2bc17f0215
commit
ee94df33ad
|
@ -39,22 +39,22 @@ function loadSettings() {
|
|||
is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
|
||||
}
|
||||
|
||||
function formatHours(hh) {
|
||||
const zeroPad = (num, places) => String(num).padStart(places, '0')
|
||||
|
||||
function formatHours(h) {
|
||||
if (is12Hour) {
|
||||
let hours = parseInt(hh,10);
|
||||
if (hours == 0) {
|
||||
hours = 12;
|
||||
} else if (hours >= 12) {
|
||||
if (hours>12) hours -= 12;
|
||||
if (h == 0) {
|
||||
h = 12;
|
||||
} else if (h > 12) {
|
||||
h -= 12;
|
||||
}
|
||||
hh = (" "+hours).substr(-2);
|
||||
}
|
||||
return hh;
|
||||
return zeroPad(h, 2);
|
||||
}
|
||||
|
||||
function extractTime(d){
|
||||
var h = d.getHours(), m = d.getMinutes();
|
||||
return(formatHours(("0"+h).substr(-2)) + ":" + ("0"+m).substr(-2));
|
||||
return(formatHours(h) + ":" + zeroPad(m, 2));
|
||||
}
|
||||
|
||||
function updateSunRiseSunSet(lat, lon){
|
||||
|
@ -94,11 +94,11 @@ const wb = 40; // battery width
|
|||
function draw() {
|
||||
log_debug("draw()");
|
||||
let date = new Date();
|
||||
let da = date.toString().split(" ");
|
||||
let hh = da[4].substr(0,2);
|
||||
let mm = da[4].substr(3,2);
|
||||
let hh = date.getHours();
|
||||
let mm = date.getMinutes();
|
||||
|
||||
hh = formatHours(hh);
|
||||
mm = zeroPad(mm,2);
|
||||
|
||||
//const t = 6;
|
||||
|
||||
|
@ -136,8 +136,11 @@ function draw() {
|
|||
|
||||
function drawSideBar1() {
|
||||
let date = new Date();
|
||||
let da = date.toString().split(" ");
|
||||
let dy=require("date_utils").dow(date.getDay(),1).toUpperCase();
|
||||
let dd=date.getDate();
|
||||
let mm=require("date_utils").month(date.getMonth()+1,1).toUpperCase();
|
||||
|
||||
|
||||
drawBattery(w2 + (w-w2-wb)/2, h/10, wb, 17);
|
||||
|
||||
setTextColor();
|
||||
|
@ -145,7 +148,7 @@ function drawSideBar1() {
|
|||
g.setFontAlign(0, -1);
|
||||
g.drawString(E.getBattery() + '%', w3, (h/10) + 17 + 7);
|
||||
|
||||
drawDateAndCalendar(w3, h/2, da[0], da[2], da[1]);
|
||||
drawDateAndCalendar(w3, h/2, dy, dd, mm);
|
||||
}
|
||||
|
||||
function drawSideBar2() {
|
||||
|
|
Loading…
Reference in New Issue