Skip to content

Commit

Permalink
Fix all-day events covering a timezone change
Browse files Browse the repository at this point in the history
Fixes #3457
  • Loading branch information
cgx committed Jun 9, 2016
1 parent 49a6046 commit 4ff1007
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions UI/Scheduler/UIxAppointmentEditor.m
Expand Up @@ -315,6 +315,7 @@ - (NSCalendarDate *) newStartDate
offset = [timeZone secondsFromGMTForDate: startDate];
startDate = [startDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset];
offset = [timeZone secondsFromGMTForDate: endDate];
endDate = [endDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset];
}
Expand Down Expand Up @@ -717,16 +718,27 @@ - (void) takeValuesFromRequest: (WORequest *) _rq

if (isAllDay)
{
nbrDays = ((float) abs ([aptEndDate timeIntervalSinceDate: aptStartDate])
/ 86400) + 1;
// Convert all-day start date to GMT (floating date)
ud = [[context activeUser] userDefaults];
timeZone = [ud timeZone];
offset = [timeZone secondsFromGMTForDate: aptStartDate];
allDayStartDate = [aptStartDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:offset];
[event setAllDayWithStartDate: allDayStartDate
duration: nbrDays];
if ([aptStartDate earlierDate: aptEndDate] == aptStartDate)
{
// Remove the vTimeZone when dealing with an all-day event.
startDate = (iCalDateTime *)[event uniqueChildWithTag: @"dtstart"];
tz = [startDate timeZone];
if (tz)
{
[startDate setTimeZone: nil];
[(iCalDateTime *)[event uniqueChildWithTag: @"dtend"] setTimeZone: nil];
[[event parent] removeChild: tz];
}

nbrDays = round ([aptEndDate timeIntervalSinceDate: aptStartDate] / 86400) + 1;
// Convert all-day start date to GMT (floating date)
timeZone = [aptStartDate timeZone];
offset = [timeZone secondsFromGMTForDate: aptStartDate];
allDayStartDate = [aptStartDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:offset];
[event setAllDayWithStartDate: allDayStartDate
duration: nbrDays];
}
}
else
{
Expand All @@ -750,18 +762,6 @@ - (void) takeValuesFromRequest: (WORequest *) _rq
}
}
}
else if (![[self clientObject] isNew])
{
// Remove the vTimeZone when dealing with an all-day event.
startDate = (iCalDateTime *)[event uniqueChildWithTag: @"dtstart"];
tz = [startDate timeZone];
if (tz)
{
[startDate setTimeZone: nil];
[(iCalDateTime *)[event uniqueChildWithTag: @"dtend"] setTimeZone: nil];
[[event parent] removeChild: tz];
}
}

[event setTransparency: (isTransparent? @"TRANSPARENT" : @"OPAQUE")];

Expand Down

0 comments on commit 4ff1007

Please sign in to comment.