diff --git a/panels/ufc/script.js b/panels/ufc/script.js index 80d2041eaecaa73bafabd831e76d23d6aa6dfc58..bd69c56b793a16324001cbc4ee9d61ae1029e3c0 100644 --- a/panels/ufc/script.js +++ b/panels/ufc/script.js @@ -30,6 +30,17 @@ this.checkShowCondition=function() { return 0; } +this.dow = function(d) { + if (typeof(d)!='number' || d <= 0 || d >= 7) + return undefined; + return ["So","Mo","Di","Mi","Do","Fr,","Sa"][d]; +} +this.getLongMonth = function(month){ + if (typeof(month)!='number' || month <= 0 || month >= 12) + return undefined; + return ["Januar","Feburar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"][month]; +} + this.show=function() { var now = new Date().getTime(); if (!nextMovie || (now > new Date(nextMovie.date).getTime())) @@ -46,40 +57,20 @@ this.show=function() { titleDiv.text(nextMovie.title); var d = new Date(nextMovie.date); var tag = d.getDate(); - tag = tag<10?"0"+tag:tag; - zeitDiv.text(tag+". "+this.getLongMonth(d.getMonth())+" "+ d.getFullYear() + " " + d.toLocaleTimeString()); - this.resize(); - } -} + var h = d.getHours(); + var m = d.getMinutes(); -this.getLongMonth = function(month){ - switch(month) - { - case 1: - return "Januar"; - case 2: - return "Feburar"; - case 3: - return "März"; - case 4: - return "April"; - case 5: - return "Mai"; - case 6: - return "Juni"; - case 7: - return "Juli"; - case 8: - return "August"; - case 9: - return "September"; - case 10: - return "Oktober"; - case 11: - return "November"; - case 12: - return "Dezember"; - default: - return "undefined"; + tag = tag < 10 ? "0" + tag : tag; + h = h < 10 ? "0" + h : h; + m = m < 10 ? "0" + m : m; + + zeitDiv.text( + this.dow(d.getDay()) + ", " + + tag + ". " + + this.getLongMonth(d.getMonth()) + " " + + d.getFullYear() + " " + + h + ":" + m + ); + this.resize(); } -} +} \ No newline at end of file