2022-10-06 20:20:42 +00:00
|
|
|
const DateFormatter = require("slidingtext.dtfmt.js");
|
2021-04-21 10:09:18 +00:00
|
|
|
|
2021-10-07 07:41:19 +00:00
|
|
|
const germanNumberStr = [ ["NULL",""], // 0
|
2021-04-21 10:09:18 +00:00
|
|
|
["EINS",""], // 1
|
|
|
|
["ZWEI",""], //2
|
|
|
|
["DREI",''], //3
|
|
|
|
["VIER",''], //4
|
|
|
|
["FÜNF",''], //5
|
|
|
|
["SECHS",''], //6
|
2021-10-07 07:41:19 +00:00
|
|
|
["SIEBEN",''], //7
|
2021-04-21 10:09:18 +00:00
|
|
|
["ACHT",''], //8
|
2021-10-07 07:41:19 +00:00
|
|
|
["NEUN",''], // 9,
|
2021-04-21 10:09:18 +00:00
|
|
|
["ZEHN",''], // 10
|
|
|
|
["ELF",''], // 11,
|
2021-04-22 14:46:32 +00:00
|
|
|
["ZWÖLF",''], // 12
|
2021-04-21 10:09:18 +00:00
|
|
|
["DREI",'ZEHN'], // 13
|
|
|
|
["VIER",'ZEHN'], // 14
|
2021-04-22 14:46:32 +00:00
|
|
|
["FÜNF",'ZEHN'], // 15
|
2021-04-21 10:09:18 +00:00
|
|
|
["SECH",'ZEHN'], // 16
|
|
|
|
["SIEB",'ZEHN'], // 17
|
|
|
|
["ACHT",'ZEHN'], // 18
|
|
|
|
["NEUN",'ZEHN'], // 19
|
|
|
|
];
|
|
|
|
|
2021-10-07 07:41:19 +00:00
|
|
|
const germanTensStr = ["NULL",//0
|
2021-04-21 10:09:18 +00:00
|
|
|
"ZEHN",//10
|
|
|
|
"ZWANZIG",//20
|
2021-04-22 20:48:30 +00:00
|
|
|
"DREIßIG",//30
|
2021-04-21 10:09:18 +00:00
|
|
|
"VIERZIG",//40
|
2021-04-22 14:46:32 +00:00
|
|
|
"FÜNFZIG",//50
|
2021-04-21 10:09:18 +00:00
|
|
|
"SECHZIG"//60
|
|
|
|
]
|
|
|
|
|
|
|
|
const germanUnit = ["",//0
|
|
|
|
"EINUND",//1
|
|
|
|
"ZWEIUND",//2
|
|
|
|
"DREIUND",//3
|
|
|
|
"VIERUND", //4
|
2021-04-22 14:46:32 +00:00
|
|
|
"FÜNFUND", //5
|
2021-04-21 10:09:18 +00:00
|
|
|
"SECHSUND", //6
|
2021-10-07 07:41:19 +00:00
|
|
|
"SIEBENUND", //7
|
2021-04-21 10:09:18 +00:00
|
|
|
"ACHTUND", //8
|
|
|
|
"NEUNUND" //9
|
|
|
|
]
|
|
|
|
|
|
|
|
function germanHoursToText(hours){
|
|
|
|
hours = hours % 12;
|
2022-08-06 01:18:25 +00:00
|
|
|
if(hours === 0){
|
2021-04-21 10:09:18 +00:00
|
|
|
hours = 12;
|
|
|
|
}
|
2022-08-07 22:17:39 +00:00
|
|
|
if(hours === 1){
|
|
|
|
return "EIN"
|
|
|
|
} else {
|
|
|
|
return germanNumberStr[hours][0];
|
|
|
|
}
|
2021-04-21 10:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function germanMinsToText(mins) {
|
|
|
|
if (mins < 20) {
|
|
|
|
return germanNumberStr[mins];
|
|
|
|
} else {
|
2022-10-06 20:20:42 +00:00
|
|
|
const tens = (mins / 10 | 0);
|
|
|
|
const word1 = germanTensStr[tens];
|
|
|
|
const remainder = mins - tens * 10;
|
|
|
|
const word2 = germanUnit[remainder];
|
2021-04-21 10:09:18 +00:00
|
|
|
return [word2, word1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class GermanDateFormatter extends DateFormatter {
|
2022-08-06 01:18:25 +00:00
|
|
|
constructor() {
|
|
|
|
super();
|
2022-09-29 18:05:44 +00:00
|
|
|
this.row_types = { };
|
|
|
|
this.row_defs = [
|
|
|
|
{
|
|
|
|
type: 'large',
|
|
|
|
init_coords: [0.05,0.1],
|
|
|
|
row_direction: [0.0,1.0],
|
|
|
|
rows: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'medium',
|
|
|
|
init_coords: [0.05,0.4],
|
|
|
|
row_direction: [0.0,1.0],
|
|
|
|
rows: 3
|
2022-08-06 01:18:25 +00:00
|
|
|
}
|
2022-09-29 18:05:44 +00:00
|
|
|
];
|
2022-08-06 01:18:25 +00:00
|
|
|
}
|
2021-04-21 10:09:18 +00:00
|
|
|
formatDate(date){
|
2022-10-06 20:20:42 +00:00
|
|
|
const mins = date.getMinutes();
|
|
|
|
const hourOfDay = date.getHours();
|
2021-04-21 10:09:18 +00:00
|
|
|
var hours = germanHoursToText(hourOfDay);
|
|
|
|
//console.log('hourOfDay->' + hourOfDay + ' hours text->' + hours)
|
|
|
|
// Deal with the special times first
|
2022-08-07 22:17:39 +00:00
|
|
|
if(mins === 0){
|
2021-04-21 10:09:18 +00:00
|
|
|
return [hours,"UHR", "","",""];
|
2021-04-22 14:46:32 +00:00
|
|
|
} /*else if(mins == 30){
|
2021-04-21 10:09:18 +00:00
|
|
|
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];
|
2021-04-22 08:41:18 +00:00
|
|
|
} */ else {
|
2022-10-06 20:20:42 +00:00
|
|
|
const mins_txt = germanMinsToText(mins);
|
2021-04-21 10:09:18 +00:00
|
|
|
return [hours, "UHR", mins_txt[0],mins_txt[1]];
|
|
|
|
}
|
|
|
|
}
|
2022-09-29 18:05:44 +00:00
|
|
|
defaultRowTypes(){ return this.row_types;}
|
|
|
|
|
|
|
|
defaultRowDefs(){ return this.row_defs; }
|
2021-04-21 10:09:18 +00:00
|
|
|
}
|
|
|
|
|
2021-10-07 07:41:19 +00:00
|
|
|
module.exports = GermanDateFormatter;
|