Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recurrence part position and size after daylights saving change (T804886, first step) #11657

Merged
merged 18 commits into from
Jan 27, 2020
1 change: 1 addition & 0 deletions js/ui/scheduler/ui.scheduler.appointments.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ const SchedulerAppointments = CollectionWidget.inherit({
},

_processRecurrenceAppointment: function(appointment, index, skipLongAppointments) {
// NOTE: this method is actual only for agenda
const recurrenceRule = this.invoke('getField', 'recurrenceRule', appointment);
const result = {
parts: [],
Expand Down
29 changes: 29 additions & 0 deletions js/ui/scheduler/ui.scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,35 @@ const Scheduler = Widget.inherit({
return this._calculateTimezoneByValue(this.option('timeZone'), date);
},

_getDaylightOffsetByCustomTimezone: function(startDate, endDate) {
return this._getTimezoneOffsetByOption(startDate) - this._getTimezoneOffsetByOption(endDate);
},

_getDaylightOffsetByAppointmentTimezone: function(startDate, endDate, appointmentTimezone) {
return this._calculateTimezoneByValue(appointmentTimezone, startDate) - this._calculateTimezoneByValue(appointmentTimezone, endDate);
},

_correctDateByDaylightOffsets: function(originalStartDate, date, startDateTimezone) {
const daylightOffsetByOption = this._getDaylightOffsetByCustomTimezone(originalStartDate, date);
const daylightOffsetByAppointment = this._getDaylightOffsetByAppointmentTimezone(originalStartDate, date, startDateTimezone);
const diff = daylightOffsetByOption - daylightOffsetByAppointment;

return new Date(date.getTime() - diff * toMs('hour'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lord Howe Island
Yangon

These timezones have hours shift with the minute draw. Does this code support this kind of altitude?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the display of the appointment in this timezone, everything works as expected

},

correctDatesByDaylightOffsets: function(dates, appointmentData, originalStartDate) {
const startDateTimeZone = this.fire('getField', 'startDateTimeZone', appointmentData);
const needCheckTimezoneOffset = typeUtils.isDefined(startDateTimeZone) && typeUtils.isDefined(this._getTimezoneOffsetByOption(originalStartDate));

if(needCheckTimezoneOffset) {
dates = dates.map((date) => {
return this._correctDateByDaylightOffsets(originalStartDate, date, startDateTimeZone);
});
}

return dates;
},

_calculateTimezoneByValue: function(timezone, date) {
let result = timezone;

Expand Down
2 changes: 2 additions & 0 deletions js/ui/scheduler/ui.scheduler.subscribes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ const subscribes = {
dates.push(startDate);
initialDates = dates;
} else {
dates = this.correctDatesByDaylightOffsets(dates, appointmentData, originalStartDate);
initialDates = dates;

dates = dates.map((date) => {
return dateUtils.roundDateByStartDayHour(date, this._getCurrentViewOption('startDayHour'));
});
Expand Down
Loading