Fix all-day event dates with different timezone

This commit is contained in:
Francis Lachapelle
2019-01-14 13:05:22 -05:00
parent e883959aa0
commit ba32125ee5
2 changed files with 20 additions and 1 deletions

3
NEWS
View File

@@ -4,6 +4,9 @@
Enhancements
- [web] create card from sender or recipient address (#3002, #4610)
Bug fixes
- [web] Fix all-day event dates with different timezone
4.0.5 (2019-01-09)
------------------

View File

@@ -31,7 +31,9 @@
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <NGCards/iCalDateTime.h>
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalTimeZone.h>
#import <NGCards/iCalTrigger.h>
#import <NGCards/iCalRecurrenceRule.h>
@@ -689,7 +691,6 @@
iCalEvent *event;
BOOL resetAlarm;
NSInteger offset;
NSUInteger snoozeAlarm;
event = [self event];
@@ -703,6 +704,21 @@
if (isAllDay)
{
iCalDateTime *dt;
iCalTimeZone *tz;
NSInteger offset;
// An all-day event usually doesn't have a timezone associated to its
// start-end dates; however, if it does, we convert them to GMT.
dt = (iCalDateTime*) [event uniqueChildWithTag: @"dtstart"];
tz = [(iCalDateTime*) dt timeZone];
if (tz)
eventStartDate = [tz computedDateForDate: eventStartDate];
dt = (iCalDateTime*) [event uniqueChildWithTag: @"dtend"];
tz = [(iCalDateTime*) dt timeZone];
if (tz)
eventEndDate = [tz computedDateForDate: eventEndDate];
eventEndDate = [eventEndDate dateByAddingYears: 0 months: 0 days: -1];
// Convert the dates to the user's timezone