From 4ad8d086222b54bf878f851583ffd4d877c7b79e Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Thu, 25 Apr 2013 18:02:16 +0000 Subject: [PATCH] kiosk day of week --- raspberry-kiosk/kiosk.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/raspberry-kiosk/kiosk.js b/raspberry-kiosk/kiosk.js index 7315033..db879b5 100644 --- a/raspberry-kiosk/kiosk.js +++ b/raspberry-kiosk/kiosk.js @@ -57,6 +57,22 @@ function loadGooglePlusEvents() }); } +function weekday2str(dow) +{ + var weekday=new Array(7); + weekday[0]="So"; + weekday[1]="Mo"; + weekday[2]="Di"; + weekday[3]="Mi"; + weekday[4]="Do"; + weekday[5]="Fr"; + weekday[6]="Sa"; + weekday[7]="So"; + if (dow >=0 && dow <=7) + return weekday[dow]; + else + return ""; +} function writeCalendar(data, elem) { @@ -71,13 +87,20 @@ function writeCalendar(data, elem) } else { + var weekday = weekday2str((new Date(dt)).getDay()); var stime = data[s].starttime; + var month = data[s].start.substring(5,7); + if (month[0] == '0') + month = month[1]; + var dayofmonth = data[s].start.substring(8,10); + if (dayofmonth[0] == '0') + dayofmonth = dayofmonth[1]; while (stime.substring(stime.length-3,stime.length) == ":00") { stime=stime.substring(0,stime.length-3); } if (stime.length <= 2) { stime+="h"; } - when = data[s].start.substring(8,10)+"."+data[s].start.substring(5,7) +", "+stime; + when = weekday + " " + dayofmonth+"."+month +", "+stime; } calhtml += '
  • '+when+' - '+data[s].title+'
  • '+"\n"; } -- 1.7.10.4