Merge pull request #2748 from sdetweil/calfix

This commit is contained in:
Michael Teeuw 2021-12-24 18:00:06 +01:00 committed by GitHub
commit 512c392386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 31 deletions

View File

@ -39,6 +39,8 @@ _This release is scheduled to be released on 2022-01-01._
- Fixed User-Agent-Header for newsfeed and calendar module (#2729). - Fixed User-Agent-Header for newsfeed and calendar module (#2729).
- Replace broken shields in Readme and use https for links. - Replace broken shields in Readme and use https for links.
- Fixed electron tests with retry. - Fixed electron tests with retry.
- Fixed Calendar recurring cross timezone error (add/subtract a day, not just offset hours) (#2632)
- Fixed Calendar showEnd and Full Date overlay (#2629)
## [2.17.1] - 2021-10-01 ## [2.17.1] - 2021-10-01

View File

@ -98,7 +98,7 @@ const CalendarUtils = {
if (h > 0 && h < Math.abs(current_offset) / 60) { if (h > 0 && h < Math.abs(current_offset) / 60) {
// if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time) // if so, rrule created a wrong date (utc day, oops, with utc yesterday adjusted time)
// we need to fix that // we need to fix that
adjustHours = 24; //adjustHours = 24;
// Log.debug("adjusting date") // Log.debug("adjusting date")
} }
//-300 > -240 //-300 > -240
@ -332,38 +332,38 @@ const CalendarUtils = {
Log.debug("Fullday"); Log.debug("Fullday");
// If the offset is negative (east of GMT), where the problem is // If the offset is negative (east of GMT), where the problem is
if (dateoffset < 0) { if (dateoffset < 0) {
if (dh <= Math.abs(dateoffset / 60)) { //if (dh <= Math.abs(dateoffset / 60)) {
// reduce the time by the offset // reduce the time by the offset
// Apply the correction to the date/time to get it UTC relative // Apply the correction to the date/time to get it UTC relative
date = new Date(date.getTime() - Math.abs(dateoffset) * 60000); date = new Date(date.getTime() - Math.abs(24 * 60) * 60000);
// the duration was calculated way back at the top before we could correct the start time..
// fix it for this event entry
//duration = 24 * 60 * 60 * 1000;
Log.debug("new recurring date1 is " + date);
//}
} else {
// if the timezones are the same, correct date if needed
//if (event.start.tz === moment.tz.guess()) {
// if the date hour is less than the offset
if (24 - dh <= Math.abs(dateoffset / 60)) {
// apply the correction to the date/time back to right day
date = new Date(date.getTime() + Math.abs(24 * 60) * 60000);
// the duration was calculated way back at the top before we could correct the start time.. // the duration was calculated way back at the top before we could correct the start time..
// fix it for this event entry // fix it for this event entry
//duration = 24 * 60 * 60 * 1000; //duration = 24 * 60 * 60 * 1000;
Log.debug("new recurring date1 is " + date); Log.debug("new recurring date2 is " + date);
}
} else {
// if the timezones are the same, correct date if needed
if (event.start.tz === moment.tz.guess()) {
// if the date hour is less than the offset
if (24 - dh < Math.abs(dateoffset / 60)) {
// apply the correction to the date/time back to right day
date = new Date(date.getTime() + Math.abs(24 * 60) * 60000);
// the duration was calculated way back at the top before we could correct the start time..
// fix it for this event entry
//duration = 24 * 60 * 60 * 1000;
Log.debug("new recurring date2 is " + date);
}
} }
//}
} }
} else { } else {
// not full day, but luxon can still screw up the date on the rule processing // not full day, but luxon can still screw up the date on the rule processing
// we need to correct the date to get back to the right event for // we need to correct the date to get back to the right event for
if (dateoffset < 0) { if (dateoffset < 0) {
// if the date hour is less than the offset // if the date hour is less than the offset
if (dh < Math.abs(dateoffset / 60)) { if (dh <= Math.abs(dateoffset / 60)) {
// Reduce the time by the offset: // Reduce the time by the offset:
// Apply the correction to the date/time to get it UTC relative // Apply the correction to the date/time to get it UTC relative
date = new Date(date.getTime() - Math.abs(nowOffset) * 60000); date = new Date(date.getTime() - Math.abs(24 * 60) * 60000);
// the duration was calculated way back at the top before we could correct the start time.. // the duration was calculated way back at the top before we could correct the start time..
// fix it for this event entry // fix it for this event entry
//duration = 24 * 60 * 60 * 1000; //duration = 24 * 60 * 60 * 1000;
@ -371,17 +371,17 @@ const CalendarUtils = {
} }
} else { } else {
// if the timezones are the same, correct date if needed // if the timezones are the same, correct date if needed
if (event.start.tz === moment.tz.guess()) { //if (event.start.tz === moment.tz.guess()) {
// if the date hour is less than the offset // if the date hour is less than the offset
if (24 - dh < Math.abs(dateoffset / 60)) { if (24 - dh <= Math.abs(dateoffset / 60)) {
// apply the correction to the date/time back to right day // apply the correction to the date/time back to right day
date = new Date(date.getTime() + Math.abs(24 * 60) * 60000); date = new Date(date.getTime() + Math.abs(24 * 60) * 60000);
// the duration was calculated way back at the top before we could correct the start time.. // the duration was calculated way back at the top before we could correct the start time..
// fix it for this event entry // fix it for this event entry
//duration = 24 * 60 * 60 * 1000; //duration = 24 * 60 * 60 * 1000;
Log.debug("new recurring date2 is " + date); Log.debug("new recurring date2 is " + date);
}
} }
//}
} }
} }
startDate = moment(date); startDate = moment(date);