From 792d9a316681c31657b69aaf5f947ee3340924b6 Mon Sep 17 00:00:00 2001 From: copoer Date: Wed, 23 Feb 2022 13:18:12 -0400 Subject: [PATCH 1/4] Local for time in contour clock --- apps/contourclock/lib.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/contourclock/lib.js b/apps/contourclock/lib.js index 65a4622f4..aa83fca26 100644 --- a/apps/contourclock/lib.js +++ b/apps/contourclock/lib.js @@ -13,13 +13,15 @@ exports.drawClock = function(fontIndex) { if (n!=10) return (false); //font file seems to be invalid var x=0; var y = g.getHeight()/2-digits[0].height/2; - var date = new Date(); + var date = require('locale').time(new Date(),1); + var hours = date.split(":")[0]; + var minutes = date.split(":")[1]; g.clearRect(0,38,g.getWidth()-1,138); - d1=parseInt(date.getHours()/10); - d2=parseInt(date.getHours()%10); + d1=parseInt(hours/10); + d2=parseInt(hours%10); d3=10; - d4=parseInt(date.getMinutes()/10); - d5=parseInt(date.getMinutes()%10); + d4=parseInt(minutes/10); + d5=parseInt(minutes%10); w1=digits[d1].width; w2=digits[d2].width; w3=digits[d3].width; From da25e418058e5b85c6dfd85d91847d34ecdf7acc Mon Sep 17 00:00:00 2001 From: copoer Date: Wed, 23 Feb 2022 13:24:59 -0400 Subject: [PATCH 2/4] Change log --- apps/contourclock/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/contourclock/ChangeLog b/apps/contourclock/ChangeLog index 9c62e637b..aed7baf64 100644 --- a/apps/contourclock/ChangeLog +++ b/apps/contourclock/ChangeLog @@ -5,3 +5,4 @@ 0.23: Customizer! Unused fonts no longer take up precious memory. 0.24: Added previews to the customizer. 0.25: Fixed a bug that would let widgets change the color of the clock. +0.26: Time now works with locale formatting From 1af14f3f2c9d7f76c09f38e273e0045eda3366a6 Mon Sep 17 00:00:00 2001 From: copoer Date: Fri, 25 Feb 2022 17:11:08 -0400 Subject: [PATCH 3/4] Updated to use suggested function --- apps/contourclock/ChangeLog | 2 +- apps/contourclock/lib.js | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/apps/contourclock/ChangeLog b/apps/contourclock/ChangeLog index aed7baf64..032edc9b5 100644 --- a/apps/contourclock/ChangeLog +++ b/apps/contourclock/ChangeLog @@ -5,4 +5,4 @@ 0.23: Customizer! Unused fonts no longer take up precious memory. 0.24: Added previews to the customizer. 0.25: Fixed a bug that would let widgets change the color of the clock. -0.26: Time now works with locale formatting +0.26: Time formatted to locale diff --git a/apps/contourclock/lib.js b/apps/contourclock/lib.js index aa83fca26..c4f927953 100644 --- a/apps/contourclock/lib.js +++ b/apps/contourclock/lib.js @@ -1,3 +1,11 @@ +var is12; +function getHours(d) { + var h = d.getHours(); + if (is12===undefined) is12 = (require('Storage').readJSON('setting.json',1)||{})["12hour"]; + if (!is12) return h; + return (h%12==0) ? 12 : h%12; +} + exports.drawClock = function(fontIndex) { var digits = []; fontFile=require("Storage").read("contourclock-"+Math.abs(parseInt(fontIndex+0.5))+".json"); @@ -13,15 +21,13 @@ exports.drawClock = function(fontIndex) { if (n!=10) return (false); //font file seems to be invalid var x=0; var y = g.getHeight()/2-digits[0].height/2; - var date = require('locale').time(new Date(),1); - var hours = date.split(":")[0]; - var minutes = date.split(":")[1]; + var date = new Date(); g.clearRect(0,38,g.getWidth()-1,138); - d1=parseInt(hours/10); - d2=parseInt(hours%10); + d1=parseInt(getHours(date)/10); + d2=parseInt(getHours(date)%10); d3=10; - d4=parseInt(minutes/10); - d5=parseInt(minutes%10); + d4=parseInt(date.getMinutes()/10); + d5=parseInt(date.getMinutes()%10); w1=digits[d1].width; w2=digits[d2].width; w3=digits[d3].width; From fc740bbb1ce4f3d6011ffab1e5b665d547623207 Mon Sep 17 00:00:00 2001 From: copoer Date: Fri, 25 Feb 2022 17:14:20 -0400 Subject: [PATCH 4/4] Added version --- apps/contourclock/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contourclock/metadata.json b/apps/contourclock/metadata.json index 54d799127..ec29c390b 100644 --- a/apps/contourclock/metadata.json +++ b/apps/contourclock/metadata.json @@ -1,7 +1,7 @@ { "id": "contourclock", "name": "Contour Clock", "shortName" : "Contour Clock", - "version":"0.25", + "version":"0.26", "icon": "app.png", "description": "A Minimalist clockface with large Digits. Now with more fonts!", "screenshots" : [{"url":"cc-screenshot-1.png"},{"url":"cc-screenshot-2.png"}],