Skip to content

Commit

Permalink
sort the timezone periods chronologically, in reverse order, to ensur…
Browse files Browse the repository at this point in the history
…e that the most recent valid one is used
  • Loading branch information
Wolfgang Sourdeau committed Oct 20, 2012
1 parent 948bafd commit 5c9298f
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions SOPE/NGCards/iCalTimeZone.m
Expand Up @@ -196,22 +196,18 @@ - (NSCalendarDate *) _occurrenceForPeriodNamed: (NSString *) pName
NSArray *periods;
NSEnumerator *periodsList;
iCalTimeZonePeriod *period;
NSCalendarDate *occurence;
NSCalendarDate *occurrence;

occurence = nil;
periods = [self childrenWithTag: pName];
if ([periods count])
{
periodsList = [periods objectEnumerator];
period = (iCalTimeZonePeriod *) [periodsList nextObject];
while (occurence == nil && period)
{
occurence = [period occurenceForDate: aDate];
period = (iCalTimeZonePeriod *) [periodsList nextObject];
}
}
occurrence = nil;

periods = [[self childrenWithTag: pName]
sortedArrayUsingSelector: @selector (compare:)];
periodsList = [periods reverseObjectEnumerator];
while (!occurrence
&& (period = (iCalTimeZonePeriod *) [periodsList nextObject]))
occurrence = [period occurrenceForDate: aDate];

return occurence;
return occurrence;
}

- (iCalTimeZonePeriod *) periodForDate: (NSCalendarDate *) date
Expand Down

0 comments on commit 5c9298f

Please sign in to comment.