See SOPE/NGCards/ChangeLog.

Monotone-Parent: 99dc7d9dce88b8a323b1e7aab60de99ed2bfda60
Monotone-Revision: d29498142c4a9f1d780373bd5f0d80b17f6e2c33

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2012-05-30T11:34:24
maint-2.0.2
Francis Lachapelle 2012-05-30 11:34:24 +00:00
parent d6f0203351
commit d98db782b3
5 changed files with 53 additions and 23 deletions

View File

@ -1,3 +1,9 @@
2012-05-30 Francis Lachapelle <flachapelle@inverse.ca>
* iCalRepeatableEntityObject.m (-exceptionDatesWithTimeZone:)
(-rules:withTimeZone:): exception dates and exception rules must
also be adjusted for floating all-day repeating events.
2012-05-29 Francis Lachapelle <flachapelle@inverse.ca> 2012-05-29 Francis Lachapelle <flachapelle@inverse.ca>
* iCalRecurrenceCalculator.m * iCalRecurrenceCalculator.m

View File

@ -201,7 +201,9 @@ static Class yearlyCalcClass = Nil;
compare = [[currentRange startDate] compare: currentDate]; compare = [[currentRange startDate] compare: currentDate];
if ((compare == NSOrderedAscending || compare == NSOrderedSame) && if ((compare == NSOrderedAscending || compare == NSOrderedSame) &&
[[currentRange endDate] compare: currentDate] == NSOrderedDescending) [[currentRange endDate] compare: currentDate] == NSOrderedDescending)
[ranges removeObjectAtIndex: count - 1]; {
[ranges removeObjectAtIndex: count - 1];
}
} }
} }
} }

View File

@ -42,21 +42,21 @@
- (void)setRecurrenceRules:(NSArray *)_rrule; - (void)setRecurrenceRules:(NSArray *)_rrule;
- (BOOL)hasRecurrenceRules; - (BOOL)hasRecurrenceRules;
- (NSArray *)recurrenceRules; - (NSArray *)recurrenceRules;
- (NSArray *)recurrenceRulesWithTimeZone: (iCalTimeZone *) timezone; - (NSArray *)recurrenceRulesWithTimeZone: (id) timezone;
- (void)removeAllExceptionRules; - (void)removeAllExceptionRules;
- (void)addToExceptionRules:(id)_rrule; - (void)addToExceptionRules:(id)_rrule;
- (BOOL)hasExceptionRules; - (BOOL)hasExceptionRules;
- (NSArray *)exceptionRules; - (NSArray *)exceptionRules;
- (NSArray *)exceptionRulesWithTimeZone: (iCalTimeZone *) timezone; - (NSArray *)exceptionRulesWithTimeZone: (id) timezone;
- (void)removeAllExceptionDates; - (void)removeAllExceptionDates;
- (void)addToExceptionDates:(NSCalendarDate *)_date; - (void)addToExceptionDates:(NSCalendarDate *)_date;
- (BOOL)hasExceptionDates; - (BOOL)hasExceptionDates;
- (NSArray *)exceptionDates; - (NSArray *)exceptionDates;
- (NSArray *)exceptionDatesWithTimeZone: (iCalTimeZone*) theTimeZone; - (NSArray *)exceptionDatesWithTimeZone: (id) theTimeZone;
- (NSArray *) rules: (NSArray *) theRules withTimeZone: (iCalTimeZone *) theTimeZone; - (NSArray *) rules: (NSArray *) theRules withTimeZone: (id) theTimeZone;
- (BOOL)isRecurrent; - (BOOL)isRecurrent;
- (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range - (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range

View File

@ -1,6 +1,6 @@
/* /*
Copyright (C) 2004-2005 SKYRIX Software AG Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2011 Inverse inc. Copyright (C) 2012 Inverse inc.
This file is part of SOPE. This file is part of SOPE.
@ -24,10 +24,12 @@
#import <Foundation/NSCalendarDate.h> #import <Foundation/NSCalendarDate.h>
#import <Foundation/NSEnumerator.h> #import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
#import <NGExtensions/NGCalendarDateRange.h> #import <NGExtensions/NGCalendarDateRange.h>
#import "NSCalendarDate+NGCards.h" #import "NSCalendarDate+NGCards.h"
#import "NSString+NGCards.h"
#import "iCalDateTime.h" #import "iCalDateTime.h"
#import "iCalEvent.h" #import "iCalEvent.h"
#import "iCalTimeZone.h" #import "iCalTimeZone.h"
@ -79,7 +81,7 @@
return [self childrenWithTag: @"rrule"]; return [self childrenWithTag: @"rrule"];
} }
- (NSArray *) recurrenceRulesWithTimeZone: (iCalTimeZone *) timezone - (NSArray *) recurrenceRulesWithTimeZone: (id) timezone
{ {
NSArray *rules; NSArray *rules;
@ -113,7 +115,7 @@
return [self childrenWithTag: @"exrule"]; return [self childrenWithTag: @"exrule"];
} }
- (NSArray *) exceptionRulesWithTimeZone: (iCalTimeZone *) timezone - (NSArray *) exceptionRulesWithTimeZone: (id) timezone
{ {
NSArray *rules; NSArray *rules;
@ -131,12 +133,13 @@
* @see exceptionRulesWithTimeZone: * @see exceptionRulesWithTimeZone:
* @return a new array of iCalRecurrenceRule instances, adjusted for the timezone. * @return a new array of iCalRecurrenceRule instances, adjusted for the timezone.
*/ */
- (NSArray *) rules: (NSArray *) theRules withTimeZone: (iCalTimeZone *) theTimeZone - (NSArray *) rules: (NSArray *) theRules withTimeZone: (id) theTimeZone
{ {
NSArray *rules; NSArray *rules;
NSCalendarDate *untilDate; NSCalendarDate *untilDate;
NSMutableArray *fixedRules; NSMutableArray *fixedRules;
iCalRecurrenceRule *currentRule; iCalRecurrenceRule *currentRule;
int offset;
unsigned int max, count; unsigned int max, count;
rules = theRules; rules = theRules;
@ -152,7 +155,14 @@
untilDate = [currentRule untilDate]; untilDate = [currentRule untilDate];
if (untilDate) if (untilDate)
{ {
untilDate = [theTimeZone computedDateForDate: untilDate]; if ([theTimeZone isKindOfClass: [iCalTimeZone class]])
untilDate = [(iCalTimeZone *) theTimeZone computedDateForDate: untilDate];
else
{
offset = [(NSTimeZone *) theTimeZone secondsFromGMTForDate: untilDate];
untilDate = (NSCalendarDate *) [untilDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset];
}
[currentRule setUntilDate: untilDate]; [currentRule setUntilDate: untilDate];
} }
[fixedRules addObject: currentRule]; [fixedRules addObject: currentRule];
@ -232,12 +242,13 @@
* @see [iCalTimeZone computedDatesForStrings:] * @see [iCalTimeZone computedDatesForStrings:]
* @return the exception dates, adjusted to the timezone. * @return the exception dates, adjusted to the timezone.
*/ */
- (NSArray *) exceptionDatesWithTimeZone: (iCalTimeZone *) theTimeZone - (NSArray *) exceptionDatesWithTimeZone: (id) theTimeZone
{ {
NSArray *dates, *exDates; NSArray *dates, *exDates;
NSEnumerator *dateList; NSEnumerator *dateList;
NSCalendarDate *exDate; NSCalendarDate *exDate;
NSString *dateString; NSString *dateString;
int offset;
unsigned i; unsigned i;
if (theTimeZone) if (theTimeZone)
@ -251,9 +262,19 @@
for (i = 0; i < [exDates count]; i++) for (i = 0; i < [exDates count]; i++)
{ {
dateString = [exDates objectAtIndex: i]; dateString = [exDates objectAtIndex: i];
exDate = [theTimeZone computedDateForString: dateString]; if ([theTimeZone isKindOfClass: [iCalTimeZone class]])
{
exDate = [(iCalTimeZone *) theTimeZone computedDateForString: dateString];
}
else
{
exDate = [dateString asCalendarDate];
offset = [(NSTimeZone *) theTimeZone secondsFromGMTForDate: exDate];
exDate = (NSCalendarDate *) [exDate dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset];
}
[(NSMutableArray *) dates addObject: exDate]; [(NSMutableArray *) dates addObject: exDate];
} }
} }
} }
else else

View File

@ -125,9 +125,7 @@
NSArray *ranges; NSArray *ranges;
NGCalendarDateRange *checkRange, *firstRange; NGCalendarDateRange *checkRange, *firstRange;
NSCalendarDate *startDate, *endDate; NSCalendarDate *startDate, *endDate;
NSTimeZone *timeZone; id firstStartDate, firstEndDate, timeZone;
id firstStartDate, firstEndDate;
iCalTimeZone *eventTimeZone;
BOOL doesOccur; BOOL doesOccur;
int offset; int offset;
@ -139,9 +137,11 @@
// Set the range to check with respect to the event timezone (extracted from the start date) // Set the range to check with respect to the event timezone (extracted from the start date)
firstStartDate = (iCalDateTime *)[self uniqueChildWithTag: @"dtstart"]; firstStartDate = (iCalDateTime *)[self uniqueChildWithTag: @"dtstart"];
eventTimeZone = [(iCalDateTime *)firstStartDate timeZone]; timeZone = [(iCalDateTime *)firstStartDate timeZone];
if (eventTimeZone) if (timeZone)
startDate = [eventTimeZone computedDateForDate: theOccurenceDate]; {
startDate = [(iCalTimeZone *)timeZone computedDateForDate: theOccurenceDate];
}
else else
{ {
startDate = theOccurenceDate; startDate = theOccurenceDate;
@ -150,13 +150,14 @@
// The event lasts all-day and has no timezone (floating); we convert the range of the first event // The event lasts all-day and has no timezone (floating); we convert the range of the first event
// to the occurence's timezone. // to the occurence's timezone.
timeZone = [theOccurenceDate timeZone]; timeZone = [theOccurenceDate timeZone];
offset = [timeZone secondsFromGMTForDate: [firstRange startDate]]; offset = [(NSTimeZone *)timeZone secondsFromGMTForDate: [firstRange startDate]];
firstStartDate = (NSCalendarDate *)[[firstRange startDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 firstStartDate = (NSCalendarDate *)[[firstRange startDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset]; seconds:-offset];
firstEndDate = (NSCalendarDate *)[[firstRange endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0 firstEndDate = (NSCalendarDate *)[[firstRange endDate] dateByAddingYears:0 months:0 days:0 hours:0 minutes:0
seconds:-offset]; seconds:-offset];
[(NSCalendarDate *)firstStartDate setTimeZone: timeZone]; [(NSCalendarDate *)firstStartDate setTimeZone: timeZone];
[(NSCalendarDate *)firstEndDate setTimeZone: timeZone]; [(NSCalendarDate *)firstEndDate setTimeZone: timeZone];
firstRange = [NGCalendarDateRange calendarDateRangeWithStartDate: firstStartDate firstRange = [NGCalendarDateRange calendarDateRangeWithStartDate: firstStartDate
endDate: firstEndDate]; endDate: firstEndDate];
} }
@ -168,9 +169,9 @@
// Calculate the occurrences for the given date // Calculate the occurrences for the given date
ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange: checkRange ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange: checkRange
firstInstanceCalendarDateRange: firstRange firstInstanceCalendarDateRange: firstRange
recurrenceRules: [self recurrenceRulesWithTimeZone: eventTimeZone] recurrenceRules: [self recurrenceRulesWithTimeZone: timeZone]
exceptionRules: [self exceptionRulesWithTimeZone: eventTimeZone] exceptionRules: [self exceptionRulesWithTimeZone: timeZone]
exceptionDates: [self exceptionDatesWithTimeZone: eventTimeZone]]; exceptionDates: [self exceptionDatesWithTimeZone: timeZone]];
doesOccur = [ranges dateRangeArrayContainsDate: startDate]; doesOccur = [ranges dateRangeArrayContainsDate: startDate];
} }