Calendar: Fix week view's now line jumped to wrong day for some timezones

This commit is contained in:
nathangray 2020-07-29 15:23:37 -10:00
parent d0f02afc28
commit 839a0e54a6
6 changed files with 9 additions and 10 deletions

View File

@ -832,8 +832,6 @@ var et2_calendar_planner = /** @class */ (function (_super) {
this.now_div.hide(); this.now_div.hide();
return false; return false;
} }
// Planner uses the dates, not just the times so need things right
now = new Date(now.valueOf() - now.getTimezoneOffset() * 60000);
var row = null; var row = null;
for (var i = 0; i < this._children.length && row == null; i++) { for (var i = 0; i < this._children.length && row == null; i++) {
if (this._children[i].instanceOf(et2_widget_planner_row_1.et2_calendar_planner_row)) { if (this._children[i].instanceOf(et2_widget_planner_row_1.et2_calendar_planner_row)) {

View File

@ -1071,8 +1071,6 @@ export class et2_calendar_planner extends et2_calendar_view implements et2_IDeta
return false; return false;
} }
// Planner uses the dates, not just the times so need things right
now = new Date(now.valueOf() - now.getTimezoneOffset()*60000);
let row = null; let row = null;
for(let i = 0; i < this._children.length && row == null; i++) for(let i = 0; i < this._children.length && row == null; i++)
{ {

View File

@ -521,7 +521,7 @@ var et2_calendar_timegrid = /** @class */ (function (_super) {
if (day.getDate() >= now) { if (day.getDate() >= now) {
day = this.day_widgets[i - 1]; day = this.day_widgets[i - 1];
this.now_div.appendTo(day.getDOMNode()).show(); this.now_div.appendTo(day.getDOMNode()).show();
var pos = day._time_to_position(now.getHours() * 60 + now.getMinutes()); var pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes());
//this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()});
this.now_div.css('top', pos + '%'); this.now_div.css('top', pos + '%');
break; break;

View File

@ -714,7 +714,7 @@ export class et2_calendar_timegrid extends et2_calendar_view implements et2_IDet
{ {
day = this.day_widgets[i-1]; day = this.day_widgets[i-1];
this.now_div.appendTo(day.getDOMNode()).show(); this.now_div.appendTo(day.getDOMNode()).show();
let pos = day._time_to_position(now.getHours() * 60 + now.getMinutes()); let pos = day._time_to_position(now.getUTCHours() * 60 + now.getUTCMinutes());
//this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()}); //this.now_div.position({my: 'left', at: 'left', of: day.getDOMNode()});
this.now_div.css('top', pos + '%'); this.now_div.css('top', pos + '%');
break; break;

View File

@ -293,9 +293,10 @@ var et2_calendar_view = /** @class */ (function (_super) {
* @private * @private
*/ */
et2_calendar_view.prototype._updateNow = function () { et2_calendar_view.prototype._updateNow = function () {
var now = new Date(); var tempDate = new Date();
var now = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(), tempDate.getHours(), tempDate.getMinutes() - tempDate.getTimezoneOffset(), 0);
// Use date widget's existing functions to deal // Use date widget's existing functions to deal
this._date_helper.set_value(now); this._date_helper.set_value(now.toJSON());
now = new Date(this._date_helper.getValue()); now = new Date(this._date_helper.getValue());
if (this.get_start_date() <= now && this.get_end_date() >= now) { if (this.get_start_date() <= now && this.get_end_date() >= now) {
return now; return now;

View File

@ -365,9 +365,11 @@ export class et2_calendar_view extends et2_valueWidget
*/ */
public _updateNow() public _updateNow()
{ {
let now = new Date(); var tempDate = new Date();
var now = new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate(),tempDate.getHours(),tempDate.getMinutes()-tempDate.getTimezoneOffset(),0);
// Use date widget's existing functions to deal // Use date widget's existing functions to deal
this._date_helper.set_value(now); this._date_helper.set_value(now.toJSON());
now = new Date(this._date_helper.getValue()); now = new Date(this._date_helper.getValue());
if(this.get_start_date() <= now && this.get_end_date() >= now) if(this.get_start_date() <= now && this.get_end_date() >= now)