Updated to use suggested function
parent
da25e41805
commit
1af14f3f2c
|
|
@ -5,4 +5,4 @@
|
||||||
0.23: Customizer! Unused fonts no longer take up precious memory.
|
0.23: Customizer! Unused fonts no longer take up precious memory.
|
||||||
0.24: Added previews to the customizer.
|
0.24: Added previews to the customizer.
|
||||||
0.25: Fixed a bug that would let widgets change the color of the clock.
|
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
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
exports.drawClock = function(fontIndex) {
|
||||||
var digits = [];
|
var digits = [];
|
||||||
fontFile=require("Storage").read("contourclock-"+Math.abs(parseInt(fontIndex+0.5))+".json");
|
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
|
if (n!=10) return (false); //font file seems to be invalid
|
||||||
var x=0;
|
var x=0;
|
||||||
var y = g.getHeight()/2-digits[0].height/2;
|
var y = g.getHeight()/2-digits[0].height/2;
|
||||||
var date = require('locale').time(new Date(),1);
|
var date = new Date();
|
||||||
var hours = date.split(":")[0];
|
|
||||||
var minutes = date.split(":")[1];
|
|
||||||
g.clearRect(0,38,g.getWidth()-1,138);
|
g.clearRect(0,38,g.getWidth()-1,138);
|
||||||
d1=parseInt(hours/10);
|
d1=parseInt(getHours(date)/10);
|
||||||
d2=parseInt(hours%10);
|
d2=parseInt(getHours(date)%10);
|
||||||
d3=10;
|
d3=10;
|
||||||
d4=parseInt(minutes/10);
|
d4=parseInt(date.getMinutes()/10);
|
||||||
d5=parseInt(minutes%10);
|
d5=parseInt(date.getMinutes()%10);
|
||||||
w1=digits[d1].width;
|
w1=digits[d1].width;
|
||||||
w2=digits[d2].width;
|
w2=digits[d2].width;
|
||||||
w3=digits[d3].width;
|
w3=digits[d3].width;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue