diff --git a/calendar/js/app.js b/calendar/js/app.js index 2e0312f7ee..bba3fece83 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -571,7 +571,7 @@ app.classes.calendar = AppJS.extend( "transform": direction == "up" ? "translateY(-50%)" : "translateX(-50%)" }); // Stop browser from caching style by forcing reflow - wrapper[0].offsetHeight; + if(wrapper[0]) wrapper[0].offsetHeight; wrapper.css({ "transition-duration": "", @@ -2853,8 +2853,7 @@ app.classes.calendar = AppJS.extend( // Avoid a full state update, we just want the calendar to update // Directly update to avoid change event from the sidebox calendar var date = new Date(this.nextSibling.dataset.year,this.nextSibling.dataset.month,this.nextSibling.firstChild.textContent,0,0,0); - date.setUTCHours(0); - date.setUTCMinutes(0); + date.setUTCMinutes(date.getUTCMinutes() - date.getTimezoneOffset()); date = app.calendar.date.toString(date); // Set to week view, if in one of the views where we change view @@ -3305,12 +3304,13 @@ jQuery.extend(app.classes.calendar,{ if(d.getUTCDate() < 15) { d.setUTCDate(1); - return app.calendar.date.start_of_week(d); - } - else - { - return app.calendar.date.start_of_week(d); } + d = app.calendar.date.start_of_week(d); + d.setUTCHours(0); + d.setUTCMinutes(0); + d.setUTCSeconds(0); + d.setUTCMilliseconds(0); + return d; } return d; }, diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 7b0eb17ad8..cae7cfc93a 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -1015,11 +1015,11 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize var state = '' // we're not using UTC so date() formatting function works - var t = new Date(start.valueOf() + start.getTimezoneOffset() * 60 * 1000); + var t = new Date(start.valueOf()); // Make sure we're lining up on the week var week_end = app.calendar.date.end_of_week(start); - var days_in_week = ((week_end-start ) / (24*3600*1000))+1; + var days_in_week = Math.floor(((week_end-start ) / (24*3600*1000))+1); var week_width = 100 / days * (days <= 7 ? days : days_in_week); for(var left = 0,i = 0; i < days; t.setUTCDate(t.getUTCDate() + 7),left += week_width) { @@ -1028,11 +1028,26 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize { days_in_week = days-i; } + var usertime = new Date(t.valueOf()); + if(start.getTimezoneOffset() < 0) + { + // Gets the right week # east of GMT. West does not need it(?) + usertime.setUTCMinutes(usertime.getUTCMinutes() - start.getTimezoneOffset()); + } week_width = 100 / days * Math.min(days, days_in_week); - var title = app.calendar.egw.lang('Week')+' '+app.calendar.date.week_number(t); - state = app.calendar.date.start_of_week(new Date(t.valueOf() - start.getTimezoneOffset() * 60 * 1000)).toJSON(); + var title = app.calendar.egw.lang('Week')+' '+app.calendar.date.week_number(usertime); + + if(start.getTimezoneOffset() > 0) + { + // Gets the right week start west of GMT + usertime.setUTCMinutes(usertime.getUTCMinutes() +start.getTimezoneOffset()) + } + state = app.calendar.date.start_of_week(usertime); + state.setUTCHours(0); + state.setUTCMinutes(0); + state = state.toJSON(); if (days <= 7) { // prev. week @@ -1058,7 +1073,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize i+= days_in_week; if(days_in_week != 7) { - t.setUTCDate(t.getUTCDate() - days_in_week); + t.setUTCDate(t.getUTCDate() - (7 - days_in_week)); days_in_week = 7; } }