[FIX] web_calendar: date start and record move

The calendar view display records with the start corresponding to the
record field set as `date_start`, and the stop to the record field set
as `date_stop`.

Since ef886aed2 there some issue when mingling calendar with
`date_start` or `date_stop` date fields and `all_day` unset:

- if user had timezone between UTC+8 and UTC+14, when moving as
  "All day", the record start would be saved on the previous day.

- if used had timezone between UTC-12 and UTC-5, when moving as
  "All day", the record end would get on the following day.

- if the event was moved onto a given time (in the "Day view"), the
  event start would be set to the previous day if it was before midnight
  in UTC time, and the end would be set on the following day if it was
  after UTC 23:59.

The source of the issue was that after ef886aed2 a datetime was always
sent to the server, so depending on the browser timezone the server
could for example receive '2017-04-27 23:00' instead of '2017-04-28'.

This fix go back to the previous behavior.

fixes #15540
opw-15540
closes #16698
This commit is contained in:
Nicolas Lempereur
2017-04-28 18:01:32 +08:00
parent 283b648c18
commit a9da6e9f3f
@@ -694,17 +694,17 @@ var CalendarView = View.extend({
date_start_day = new Date(event.start.getFullYear(),event.start.getMonth(),event.start.getDate(),7);
date_stop_day = new Date(event_end.getFullYear(),event_end.getMonth(),event_end.getDate(),19);
}
data[this.date_start] = time.datetime_to_str(date_start_day);
data[this.date_start] = time.auto_date_to_str(date_start_day, this.fields[this.date_start].type);
if (this.date_stop) {
data[this.date_stop] = time.datetime_to_str(date_stop_day);
data[this.date_stop] = time.auto_date_to_str(date_stop_day, this.fields[this.date_stop].type);
}
diff_seconds = Math.round((date_stop_day.getTime() - date_start_day.getTime()) / 1000);
}
else {
data[this.date_start] = time.datetime_to_str(event.start);
data[this.date_start] = time.auto_date_to_str(event.start, this.fields[this.date_start].type);
if (this.date_stop) {
data[this.date_stop] = time.datetime_to_str(event_end);
data[this.date_stop] = time.auto_date_to_str(event_end, this.fields[this.date_stop].type);
}
diff_seconds = Math.round((event_end.getTime() - event.start.getTime()) / 1000);
}