From f3d166a6c5cd8317e0702bb5e709bd6efaa64ad9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 29 Oct 2015 19:47:01 +0000 Subject: [PATCH] Fix wrong date headers after crossing DST east of Greenwich --- calendar/js/app.js | 11 ++++++----- calendar/js/et2_widget_daycol.js | 4 ++-- calendar/js/et2_widget_timegrid.js | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 6373db12c0..9d2ca4658e 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1709,18 +1709,19 @@ app.classes.calendar = AppJS.extend( { var val = { id: ""+date.getUTCFullYear() + sprintf("%02d",date.getUTCMonth()) + sprintf("%02d",date.getUTCDate()), - start_date: new Date(date), - end_date: new Date(date), + start_date: date.toJSON(), + end_date: new Date(date.toJSON()), owner: state.state.owner }; val.end_date.setUTCHours(24*7-1); + val.end_date = val.end_date.toJSON(); value.push(val); date.setUTCHours(24*7); } state.state.last=val.end_date; break; default: - var end = state.state.last = view.end_date(state.state); + var end = state.state.last = view.end_date(state.state).toJSON(); for(var owner = 0; owner < grid_count && owner < state.state.owner.length; owner++) { value.push({ @@ -1732,7 +1733,6 @@ app.classes.calendar = AppJS.extend( } break; } - state.state.last = state.state.last.toJSON() // If we have cached data for the timespan, pass it along this._need_data(value,state.state); if(grid) @@ -2584,7 +2584,8 @@ app.classes.calendar = AppJS.extend( date.setUTCDate(1); date.setFullYear(year); date.setUTCMonth(month-1); - var state = {date: date}; + // Use toJSON() to get UTC, not browser timezone + var state = {date: date.toJSON()}; if(app.calendar.sidebox_changes_views.indexOf(app.calendar.state.view) >= 0) { state.view = 'month'; diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 4680c93cea..ed754914fc 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -215,8 +215,8 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea else if(typeof _date === "string") { // Need a new date to avoid invalid month/date combinations when setting - // month then day - this._parent.date_helper.set_value(new Date(_date.substring(0,4),_date.substring(4,6)-1,_date.substring(6,8),-new Date().getTimezoneOffset()/60,0,0)); + // month then day. Use a string to avoid browser timezone. + this._parent.date_helper.set_value(_date.substring(0,4)+'-'+(_date.substring(4,6))+'-'+_date.substring(6,8)+'T00:00:00Z'); } this.date = new Date(this._parent.date_helper.getValue()); diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 7e9eb69c5d..e379ea34c6 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -506,7 +506,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz var rowHeight = (100/rowsToDisplay).toFixed(1); // Pixels this.rowHeight = this.div.height() / rowsToDisplay; -debugger; + this.gridHeader .empty() .attr('data-date', this.options.start_date)