mirror of https://github.com/espruino/BangleApps
Sliding Clock: Adding german 24 hour clock
parent
980bba32ca
commit
712d37a9a6
|
@ -19,7 +19,9 @@
|
||||||
{"name":"slidingtext.locale.es.js","url":"slidingtext.locale.es.js"},
|
{"name":"slidingtext.locale.es.js","url":"slidingtext.locale.es.js"},
|
||||||
{"name":"slidingtext.locale.fr.js","url":"slidingtext.locale.fr.js"},
|
{"name":"slidingtext.locale.fr.js","url":"slidingtext.locale.fr.js"},
|
||||||
{"name":"slidingtext.locale.jp.js","url":"slidingtext.locale.jp.js"},
|
{"name":"slidingtext.locale.jp.js","url":"slidingtext.locale.jp.js"},
|
||||||
|
{"name":"slidingtext.utils.de.js","url":"slidingtext.utils.de.js"},
|
||||||
{"name":"slidingtext.locale.de.js","url":"slidingtext.locale.de.js"},
|
{"name":"slidingtext.locale.de.js","url":"slidingtext.locale.de.js"},
|
||||||
|
{"name":"slidingtext.locale.de2.js","url":"slidingtext.locale.de2.js"},
|
||||||
{"name":"slidingtext.locale.dgt.js","url":"slidingtext.locale.dgt.js"},
|
{"name":"slidingtext.locale.dgt.js","url":"slidingtext.locale.dgt.js"},
|
||||||
{"name":"slidingtext.locale.hyb.js","url":"slidingtext.locale.hyb.js"},
|
{"name":"slidingtext.locale.hyb.js","url":"slidingtext.locale.hyb.js"},
|
||||||
{"name":"slidingtext.dtfmt.js","url":"slidingtext.dtfmt.js"}
|
{"name":"slidingtext.dtfmt.js","url":"slidingtext.dtfmt.js"}
|
||||||
|
|
|
@ -330,7 +330,7 @@ function initDisplay(settings) {
|
||||||
vsmall: [20,15],
|
vsmall: [20,15],
|
||||||
ssmall: [22,17],
|
ssmall: [22,17],
|
||||||
small: [25,20],
|
small: [25,20],
|
||||||
msmall: [28,22],
|
msmall: [29,22],
|
||||||
medium: [40,25],
|
medium: [40,25],
|
||||||
mlarge: [45,35],
|
mlarge: [45,35],
|
||||||
large: [50,40],
|
large: [50,40],
|
||||||
|
|
|
@ -1,72 +1,10 @@
|
||||||
const DateFormatter = require("slidingtext.dtfmt.js");
|
const DateFormatter = require("slidingtext.dtfmt.js");
|
||||||
|
const germanHoursToText = require("slidingtext.utils.de.js").germanHoursToText;
|
||||||
|
const germanMinsToText = require("slidingtext.utils.de.js").germanMinsToText;
|
||||||
|
|
||||||
const germanNumberStr = [ ["NULL",""], // 0
|
/**
|
||||||
["EINS",""], // 1
|
* German 12 hour clock
|
||||||
["ZWEI",""], //2
|
*/
|
||||||
["DREI",''], //3
|
|
||||||
["VIER",''], //4
|
|
||||||
["FÜNF",''], //5
|
|
||||||
["SECHS",''], //6
|
|
||||||
["SIEBEN",''], //7
|
|
||||||
["ACHT",''], //8
|
|
||||||
["NEUN",''], // 9,
|
|
||||||
["ZEHN",''], // 10
|
|
||||||
["ELF",''], // 11,
|
|
||||||
["ZWÖLF",''], // 12
|
|
||||||
["DREI",'ZEHN'], // 13
|
|
||||||
["VIER",'ZEHN'], // 14
|
|
||||||
["FÜNF",'ZEHN'], // 15
|
|
||||||
["SECH",'ZEHN'], // 16
|
|
||||||
["SIEB",'ZEHN'], // 17
|
|
||||||
["ACHT",'ZEHN'], // 18
|
|
||||||
["NEUN",'ZEHN'], // 19
|
|
||||||
];
|
|
||||||
|
|
||||||
const germanTensStr = ["NULL",//0
|
|
||||||
"ZEHN",//10
|
|
||||||
"ZWANZIG",//20
|
|
||||||
"DREIßIG",//30
|
|
||||||
"VIERZIG",//40
|
|
||||||
"FÜNFZIG",//50
|
|
||||||
"SECHZIG"//60
|
|
||||||
]
|
|
||||||
|
|
||||||
const germanUnit = ["",//0
|
|
||||||
"EINUND",//1
|
|
||||||
"ZWEIUND",//2
|
|
||||||
"DREIUND",//3
|
|
||||||
"VIERUND", //4
|
|
||||||
"FÜNFUND", //5
|
|
||||||
"SECHSUND", //6
|
|
||||||
"SIEBENUND", //7
|
|
||||||
"ACHTUND", //8
|
|
||||||
"NEUNUND" //9
|
|
||||||
]
|
|
||||||
|
|
||||||
function germanHoursToText(hours){
|
|
||||||
hours = hours % 12;
|
|
||||||
if(hours === 0){
|
|
||||||
hours = 12;
|
|
||||||
}
|
|
||||||
if(hours === 1){
|
|
||||||
return "EIN"
|
|
||||||
} else {
|
|
||||||
return germanNumberStr[hours][0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function germanMinsToText(mins) {
|
|
||||||
if (mins < 20) {
|
|
||||||
return germanNumberStr[mins];
|
|
||||||
} else {
|
|
||||||
const tens = (mins / 10 | 0);
|
|
||||||
const word1 = germanTensStr[tens];
|
|
||||||
const remainder = mins - tens * 10;
|
|
||||||
const word2 = germanUnit[remainder];
|
|
||||||
return [word2, word1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GermanDateFormatter extends DateFormatter {
|
class GermanDateFormatter extends DateFormatter {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -74,21 +12,10 @@ class GermanDateFormatter extends DateFormatter {
|
||||||
formatDate(date){
|
formatDate(date){
|
||||||
const mins = date.getMinutes();
|
const mins = date.getMinutes();
|
||||||
const hourOfDay = date.getHours();
|
const hourOfDay = date.getHours();
|
||||||
var hours = germanHoursToText(hourOfDay);
|
const hours = germanHoursToText(hourOfDay);
|
||||||
//console.log('hourOfDay->' + hourOfDay + ' hours text->' + hours)
|
|
||||||
// Deal with the special times first
|
|
||||||
if(mins === 0){
|
if(mins === 0){
|
||||||
return [hours,"UHR", "","",""];
|
return [hours,"UHR", "","",""];
|
||||||
} /*else if(mins == 30){
|
} else {
|
||||||
var hours = germanHoursToText(hourOfDay+1);
|
|
||||||
return ["", "", "HALB","", hours];
|
|
||||||
} else if(mins == 15){
|
|
||||||
var hours = germanHoursToText(hourOfDay);
|
|
||||||
return ["", "", "VIERTEL", "NACH",hours];
|
|
||||||
} else if(mins == 45) {
|
|
||||||
var hours = germanHoursToText(hourOfDay+1);
|
|
||||||
return ["", "", "VIERTEL", "VOR",hours];
|
|
||||||
} */ else {
|
|
||||||
const mins_txt = germanMinsToText(mins);
|
const mins_txt = germanMinsToText(mins);
|
||||||
return [hours, "UHR", mins_txt[0],mins_txt[1]];
|
return [hours, "UHR", mins_txt[0],mins_txt[1]];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
const DateFormatter = require("slidingtext.dtfmt.js");
|
||||||
|
const german24HoursToText = require("slidingtext.utils.de.js").german24HoursToText;
|
||||||
|
const germanMinsToText = require("slidingtext.utils.de.js").germanMinsToText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* German 24 hour clock
|
||||||
|
*/
|
||||||
|
class German24HourDateFormatter extends DateFormatter {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
formatDate(date){
|
||||||
|
const mins = date.getMinutes();
|
||||||
|
const hourOfDay = date.getHours();
|
||||||
|
const hours = german24HoursToText(hourOfDay);
|
||||||
|
const display_hours = (hours[1] === '')? ["", hours[0]] : hours;
|
||||||
|
if(mins === 0){
|
||||||
|
return [display_hours[0],display_hours[1],"UHR", "","",""];
|
||||||
|
} else {
|
||||||
|
const mins_txt = germanMinsToText(mins);
|
||||||
|
|
||||||
|
return [display_hours[0],display_hours[1], "UHR", mins_txt[0],mins_txt[1]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defaultRowTypes(){ return {
|
||||||
|
large:{
|
||||||
|
size: 'mlarge'
|
||||||
|
}
|
||||||
|
};}
|
||||||
|
|
||||||
|
defaultRowDefs(){
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'large',
|
||||||
|
init_coords: [0.05,0.06],
|
||||||
|
row_direction: [0.0,1.0],
|
||||||
|
rows: 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'medium',
|
||||||
|
init_coords: [0.05,0.5],
|
||||||
|
row_direction: [0.0,1.0],
|
||||||
|
rows: 3
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = German24HourDateFormatter;
|
|
@ -9,8 +9,8 @@
|
||||||
}
|
}
|
||||||
console.log("loaded:" + JSON.stringify(settings));
|
console.log("loaded:" + JSON.stringify(settings));
|
||||||
const locale_mappings = (bangleVersion > 1)? {
|
const locale_mappings = (bangleVersion > 1)? {
|
||||||
'en' : { date_formatter: 'en' },
|
'english' : { date_formatter: 'en' },
|
||||||
'en alt': {
|
'english alt': {
|
||||||
date_formatter: 'en',
|
date_formatter: 'en',
|
||||||
row_types: {
|
row_types: {
|
||||||
large:{
|
large:{
|
||||||
|
@ -52,8 +52,8 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'en2': { date_formatter: 'en2' },
|
'english2': { date_formatter: 'en2' },
|
||||||
'en2 alt': { date_formatter: 'en2',
|
'english2 alt': { date_formatter: 'en2',
|
||||||
row_types: {
|
row_types: {
|
||||||
vsmall: {
|
vsmall: {
|
||||||
color: 'minor',
|
color: 'minor',
|
||||||
|
@ -105,18 +105,19 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
'fr': { date_formatter:'fr'},
|
'french': { date_formatter:'fr'},
|
||||||
'de': { date_formatter: 'de'},
|
'german': { date_formatter: 'de'},
|
||||||
'es': { date_formatter: 'es'},
|
'german 24h': { date_formatter: 'de2'},
|
||||||
'jp': { date_formatter: 'jp'},
|
'spanish': { date_formatter: 'es'},
|
||||||
|
'japanese': { date_formatter: 'jp'},
|
||||||
'hybrid': { date_formatter: 'hyb'},
|
'hybrid': { date_formatter: 'hyb'},
|
||||||
'digits': { date_formatter: 'dgt'},
|
'digits': { date_formatter: 'dgt'},
|
||||||
} : {
|
} : {
|
||||||
'en' : { date_formatter: 'en' },
|
'english' : { date_formatter: 'en' },
|
||||||
'fr': { date_formatter:'fr'},
|
'french': { date_formatter:'fr'},
|
||||||
'de': { date_formatter: 'de'},
|
'german': { date_formatter: 'de'},
|
||||||
'es': { date_formatter: 'es'},
|
'spanish': { date_formatter: 'es'},
|
||||||
'jp': { date_formatter: 'jp'},
|
'japanese': { date_formatter: 'jp'},
|
||||||
'hybrid': { date_formatter: 'hyb'},
|
'hybrid': { date_formatter: 'hyb'},
|
||||||
'digits': { date_formatter: 'dgt'},
|
'digits': { date_formatter: 'dgt'},
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
const germanNumberStr = [ ["NULL",""], // 0
|
||||||
|
["EINS",""], // 1
|
||||||
|
["ZWEI",""], //2
|
||||||
|
["DREI",""], //3
|
||||||
|
["VIER",""], //4
|
||||||
|
["FÜNF",""], //5
|
||||||
|
["SECHS",""], //6
|
||||||
|
["SIEBEN",""], //7
|
||||||
|
["ACHT",""], //8
|
||||||
|
["NEUN",""], // 9,
|
||||||
|
["ZEHN",""], // 10
|
||||||
|
["ELF",""], // 11,
|
||||||
|
["ZWÖLF",""], // 12
|
||||||
|
["DREI","ZEHN"], // 13
|
||||||
|
["VIER","ZEHN"], // 14
|
||||||
|
["FÜNF","ZEHN"], // 15
|
||||||
|
["SECH","ZEHN"], // 16
|
||||||
|
["SIEB","ZEHN"], // 17
|
||||||
|
["ACHT","ZEHN"], // 18
|
||||||
|
["NEUN","ZEHN"], // 19
|
||||||
|
["ZWANZIG",""], // 20
|
||||||
|
["EIN","UNDZWANZIG"], // 21
|
||||||
|
["ZWEI","UNDZWANZIG"], //22
|
||||||
|
["DREI","UNDZWANZIG"], // 23
|
||||||
|
["VIER","UNDZWANZIG"] // 24
|
||||||
|
];
|
||||||
|
|
||||||
|
const germanTensStr = ["NULL",//0
|
||||||
|
"ZEHN",//10
|
||||||
|
"ZWANZIG",//20
|
||||||
|
"DREIßIG",//30
|
||||||
|
"VIERZIG",//40
|
||||||
|
"FÜNFZIG",//50
|
||||||
|
"SECHZIG"//60
|
||||||
|
]
|
||||||
|
|
||||||
|
const germanUnit = ["",//0
|
||||||
|
"EINUND",//1
|
||||||
|
"ZWEIUND",//2
|
||||||
|
"DREIUND",//3
|
||||||
|
"VIERUND", //4
|
||||||
|
"FÜNFUND", //5
|
||||||
|
"SECHSUND", //6
|
||||||
|
"SIEBENUND", //7
|
||||||
|
"ACHTUND", //8
|
||||||
|
"NEUNUND" //9
|
||||||
|
]
|
||||||
|
|
||||||
|
function germanHoursToText(hours){
|
||||||
|
hours = hours % 12;
|
||||||
|
if(hours === 0){
|
||||||
|
hours = 12;
|
||||||
|
}
|
||||||
|
if(hours === 1){
|
||||||
|
return "EIN"
|
||||||
|
} else {
|
||||||
|
return germanNumberStr[hours][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function german24HoursToText(hours){
|
||||||
|
hours = hours % 24;
|
||||||
|
if(hours === 0){
|
||||||
|
return hours[24] ;
|
||||||
|
} else if(hours === 1){
|
||||||
|
return ["EIN",""];
|
||||||
|
} else {
|
||||||
|
return germanNumberStr[hours];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function germanMinsToText(mins) {
|
||||||
|
if (mins < 20) {
|
||||||
|
return germanNumberStr[mins];
|
||||||
|
} else {
|
||||||
|
const tens = (mins / 10 | 0);
|
||||||
|
const word1 = germanTensStr[tens];
|
||||||
|
const remainder = mins - tens * 10;
|
||||||
|
const word2 = germanUnit[remainder];
|
||||||
|
return [word2, word1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.germanMinsToText = germanMinsToText;
|
||||||
|
exports.germanHoursToText = germanHoursToText;
|
||||||
|
exports.german24HoursToText = german24HoursToText;
|
Loading…
Reference in New Issue