summaryrefslogtreecommitdiff
path: root/www/js
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-06-24 17:14:30 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-06-24 22:59:18 (GMT)
commit0cabcadb25720f28708cd2cd7c566a64a61c6837 (patch)
tree0937a9f8a91b09459a897337d89d7f36347b7719 /www/js
parent1a35f4fd6fd0f1face9702507021b03a6df6a839 (diff)
mark today vs. this week
Diffstat (limited to 'www/js')
-rw-r--r--www/js/calendar.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/www/js/calendar.js b/www/js/calendar.js
index afc2369..5df77ac 100644
--- a/www/js/calendar.js
+++ b/www/js/calendar.js
@@ -28,9 +28,9 @@ function getLastMonday() {
d.setUTCHours(12, 0, 0, 0);
var dow = d.getUTCDay()
if(dow == 0) {
- return new Date(d - (6*24*3600000));
+ return new Date(d.valueOf() - (6*24*3600000));
} else {
- return new Date(d - ((dow-1)*24*3600000));
+ return new Date(d.valueOf() - ((dow-1)*24*3600000));
}
}
@@ -38,9 +38,10 @@ function addDeltaDays(d, days) {
return new Date(d.valueOf() + (days*24*3600000))
}
-function isThisWeek(d) {
- var lastmon = getLastMonday()
- return ((d - lastmon) == 0)
+function isToday(d) {
+ var today = new Date(clock.getRDTimeMS());
+ today.setUTCHours(12, 0, 0, 0);
+ return ((d - today) == 0)
}
function addWeekClass(row, week) {
@@ -72,15 +73,13 @@ function calendar_redraw(weekstart) {
var week = get_rd_week(date.valueOf() + 7199999);
var row = $('<tr>');
addWeekClass(row, week);
- if(isThisWeek(date)) {
- row.append($('<td>').addClass('currentweek').text('*'));
- } else {
- row.append($('<td>').addClass('currentweek').text(''));
- }
row.append($('<td>').addClass('week').text(week));
row.append($('<td>').addClass('month').text(monthname_short[date.getUTCMonth()] + ' ' + date.getUTCFullYear()));
for(var d = 0; d < 7; d++) {
var col = $('<td>').text(date.getUTCDate());
+ if(isToday(date)) {
+ col.addClass('today');
+ }
row.append(col);
if(d < 6) {
date = addDeltaDays(date, 1);