multiclock - Added localisation to digi.js and timedat.js
- using the locale module for language-specific time and date formats - in timdat.js, a special date format consisting of day of week, month and day of month is used that is not available as a date pattern. Hence, it's built in place. - in timedat.js, some unused variables have been removed and lastmin now uses the number returned by the Date object directlymaster
parent
b6cc5fa45b
commit
c146cfb6cb
|
|
@ -2260,7 +2260,7 @@
|
||||||
{ "id": "multiclock",
|
{ "id": "multiclock",
|
||||||
"name": "Multi Clock",
|
"name": "Multi Clock",
|
||||||
"icon": "multiclock.png",
|
"icon": "multiclock.png",
|
||||||
"version":"0.12",
|
"version":"0.13",
|
||||||
"description": "Clock with multiple faces - Big, Analogue, Digital, Text, Time-Date.\n Switch between faces with BTN1 & BTN3",
|
"description": "Clock with multiple faces - Big, Analogue, Digital, Text, Time-Date.\n Switch between faces with BTN1 & BTN3",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,4 @@
|
||||||
0.10: Added GPS and Grid Ref clock faces
|
0.10: Added GPS and Grid Ref clock faces
|
||||||
0.11: Updated Pedometer clock to retrieve steps from either wpedom or activepedom
|
0.11: Updated Pedometer clock to retrieve steps from either wpedom or activepedom
|
||||||
0.12: Removed GPS and Grid Ref clock faces, superceded by GPS setup and Walkers Clock
|
0.12: Removed GPS and Grid Ref clock faces, superceded by GPS setup and Walkers Clock
|
||||||
|
0.13: Localised digi.js and timdat.js
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
(() => {
|
(() => {
|
||||||
|
|
||||||
|
var locale = require("locale");
|
||||||
|
|
||||||
function getFace(){
|
function getFace(){
|
||||||
|
|
||||||
var buf = Graphics.createArrayBuffer(240,92,1,{msb:true});
|
var buf = Graphics.createArrayBuffer(240,92,1,{msb:true});
|
||||||
|
|
@ -19,7 +21,7 @@ function getFace(){
|
||||||
buf.drawString(time,buf.getWidth()/2,0);
|
buf.drawString(time,buf.getWidth()/2,0);
|
||||||
buf.setFont("6x8",2);
|
buf.setFont("6x8",2);
|
||||||
buf.setFontAlign(0,-1);
|
buf.setFontAlign(0,-1);
|
||||||
var date = d.toString().substr(0,15);
|
var date = locale.dow(d, 1) + " " + locale.date(d, 1);
|
||||||
buf.drawString(date, buf.getWidth()/2, 70);
|
buf.drawString(date, buf.getWidth()/2, 70);
|
||||||
flip();
|
flip();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
(() => {
|
(() => {
|
||||||
|
var locale = require("locale");
|
||||||
|
var dayFirst = ["en_GB", "en_IN", "en_NAV", "de_DE", "nl_NL", "fr_FR", "en_NZ", "en_AU", "de_AT", "en_IL", "es_ES", "fr_BE", "de_CH", "fr_CH", "it_CH", "it_IT", "tr_TR", "pt_BR", "cs_CZ", "pt_PT"];
|
||||||
|
var withDot = ["de_DE", "nl_NL", "de_AT", "de_CH", "hu_HU", "cs_CZ", "sl_SI"];
|
||||||
|
|
||||||
function getFace(){
|
function getFace(){
|
||||||
|
|
||||||
var lastmin=-1;
|
var lastmin=-1;
|
||||||
function drawClock(){
|
function drawClock(){
|
||||||
var d=Date();
|
var d=Date();
|
||||||
if (d.getMinutes()==lastmin) return;
|
if (d.getMinutes()==lastmin) return;
|
||||||
d=d.toString().split(' ');
|
var tm=d.toString().split(' ')[4].substring(0,5);
|
||||||
var min=d[4].substr(3,2);
|
lastmin=d.getMinutes();
|
||||||
var sec=d[4].substr(-2);
|
|
||||||
var tm=d[4].substring(0,5);
|
|
||||||
var hr=d[4].substr(0,2);
|
|
||||||
lastmin=min;
|
|
||||||
g.reset();
|
g.reset();
|
||||||
g.clearRect(0,24,239,239);
|
g.clearRect(0,24,239,239);
|
||||||
var w=g.getWidth();
|
var w=g.getWidth();
|
||||||
|
|
@ -19,7 +19,16 @@
|
||||||
g.drawString(tm,4+(w-g.stringWidth(tm))/2,64);
|
g.drawString(tm,4+(w-g.stringWidth(tm))/2,64);
|
||||||
g.setFontVector(36);
|
g.setFontVector(36);
|
||||||
g.setColor(0x07ff);
|
g.setColor(0x07ff);
|
||||||
var dt=d[0]+" "+d[1]+" "+d[2];//+" "+d[3];
|
var dt=locale.dow(d, 1) + " ";
|
||||||
|
if (dayFirst.includes(locale.name)) {
|
||||||
|
dt+=d.getDate();
|
||||||
|
if (withDot.includes(locale.name)) {
|
||||||
|
dt+=".";
|
||||||
|
}
|
||||||
|
dt+=" " + locale.month(d, 1);
|
||||||
|
} else {
|
||||||
|
dt+=locale.month(d, 1) + " " + d.getDate();
|
||||||
|
}
|
||||||
g.drawString(dt,(w-g.stringWidth(dt))/2,160);
|
g.drawString(dt,(w-g.stringWidth(dt))/2,160);
|
||||||
g.flip();
|
g.flip();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue