]> err.no Git - sope/commitdiff
various bugfixes and optimizations
authorznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 2 Mar 2005 15:11:21 +0000 (15:11 +0000)
committerznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Wed, 2 Mar 2005 15:11:21 +0000 (15:11 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@608 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-ical/NGiCal/ChangeLog
sope-ical/NGiCal/NGiCal.xcode/project.pbxproj
sope-ical/NGiCal/Version
sope-ical/NGiCal/iCalRecurrenceCalculator.m

index 7409c5ec965b5c8e696bfd24f10983a969306dc3..f2ca380478838ab3c07a7517b6b4b266191c2c38 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-02  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * iCalRecurrenceCalculator.m: optimized exception date handling in
+         complex calculation method quite a bit. Fixed bugs in all calculation
+         methods by introducing checks on the desired range. (v4.5.48)
+
 2005-02-28  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * v4.5.47
index 7bedbf0d9d31461ce17fd32a99a5d899e5856aad..dda6ae5a4d63e28822659faa668bcd27a0575ee2 100644 (file)
                        );
                        buildSettings = {
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 4.5.47;
+                               DYLIB_CURRENT_VERSION = 4.5.48;
                                FRAMEWORK_SEARCH_PATHS = "\"$(USER_LIBRARY_DIR)/EmbeddedFrameworks\"";
                                FRAMEWORK_VERSION = A;
                                GCC_PRECOMPILE_PREFIX_HEADER = NO;
                        );
                        buildSettings = {
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 4.5.47;
+                               DYLIB_CURRENT_VERSION = 4.5.48;
                                FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
                                FRAMEWORK_VERSION = A;
                                GCC_PRECOMPILE_PREFIX_HEADER = YES;
index e3250f18100c991879c192fc41fc7f28d2e91c67..aa4b270737ef5c6e8f31c902248fcb21572dd4ff 100644 (file)
@@ -2,7 +2,7 @@
 
 MAJOR_VERSION=4
 MINOR_VERSION=5
-SUBMINOR_VERSION:=47
+SUBMINOR_VERSION:=48
 
 # v4.5.40 requires NGExtensions v4.5.145
 # v4.5.37 requires NGExtensions v4.5.140
index d51e845a8b24d0056f46b3866a73ef77c1bc75e9..797037e1ab4290e38964d449ed37699f8b3a67ec 100644 (file)
@@ -103,6 +103,7 @@ static Class yearlyCalcClass  = Nil;
   id                       rule;
   iCalRecurrenceCalculator *calc;
   NSMutableArray           *ranges;
+  NSMutableArray           *exDates;
   unsigned                 i, count, rCount;
   
   ranges = [NSMutableArray array];
@@ -141,22 +142,46 @@ static Class yearlyCalcClass  = Nil;
   if (![ranges count])
     return nil;
   
-  /* exception dates are also possible */
-  rCount = [ranges count];
+  /* exception dates */
+
   count  = [_exDates count];
+  if (!count) return ranges;
+
+  /* sort out exDates not within range */
+
+  exDates = [NSMutableArray arrayWithCapacity:count];
   for (i = 0; i < count; i++) {
-    id                  exDate;
-    NGCalendarDateRange *r;
-    unsigned            k;
+    id exDate;
 
     exDate = [_exDates objectAtIndex:i];
     if (![exDate isKindOfClass:NSCalendarDateClass]) {
       exDate = [NSCalendarDate calendarDateWithICalRepresentation:exDate];
     }
+    if ([_r containsDate:exDate])
+      [exDates addObject:exDate];
+  }
+
+  /* remove matching exDates from ranges */
+
+  count  = [exDates count];
+  if (!count) return ranges;
+
+  rCount = [ranges count];
+  for (i = 0; i < count; i++) {
+    NSCalendarDate      *exDate;
+    NGCalendarDateRange *r;
+    unsigned            k;
+
+    exDate = [exDates objectAtIndex:i];
     for (k = 0; k < rCount; k++) {
-      r = [ranges objectAtIndex:(rCount - k) - 1];
+      unsigned rIdx;
+      
+      rIdx = (rCount - k) - 1;
+      r    = [ranges objectAtIndex:rIdx];
       if ([r containsDate:exDate]) {
-        [ranges removeObjectAtIndex:k];
+        [ranges removeObjectAtIndex:rIdx];
+        rCount--;
+        break; /* this is safe because we know that ranges don't overlap */
       }
     }
   }
@@ -340,7 +365,8 @@ static Class yearlyCalcClass  = Nil;
         end   = [start addTimeInterval:[self->firstRange duration]];
         r     = [NGCalendarDateRange calendarDateRangeWithStartDate:start
                                      endDate:end];
-        [ranges addObject:r];
+        if ([_r containsDateRange:r])
+          [ranges addObject:r];
       }
     }
   }
@@ -437,7 +463,8 @@ static Class yearlyCalcClass  = Nil;
           end   = [start addTimeInterval:[self->firstRange duration]];
           r     = [NGCalendarDateRange calendarDateRangeWithStartDate:start
                                        endDate:end];
-          [ranges addObject:r];
+          if ([_r containsDateRange:r])
+            [ranges addObject:r];
         }
       }
     }
@@ -485,7 +512,8 @@ static Class yearlyCalcClass  = Nil;
             end   = [start addTimeInterval:[self->firstRange duration]];
             r     = [NGCalendarDateRange calendarDateRangeWithStartDate:start
                                          endDate:end];
-            [ranges addObject:r];
+            if ([_r containsDateRange:r])
+              [ranges addObject:r];
           }
         }
       }
@@ -553,7 +581,8 @@ static Class yearlyCalcClass  = Nil;
       end   = [start addTimeInterval:[self->firstRange duration]];
       r     = [NGCalendarDateRange calendarDateRangeWithStartDate:start
                                    endDate:end];
-      [ranges addObject:r];
+      if ([_r containsDateRange:r])
+        [ranges addObject:r];
     }
   }
   return ranges;
@@ -614,7 +643,8 @@ static Class yearlyCalcClass  = Nil;
       end   = [start addTimeInterval:[self->firstRange duration]];
       r     = [NGCalendarDateRange calendarDateRangeWithStartDate:start
                                    endDate:end];
-      [ranges addObject:r];
+      if ([_r containsDateRange:r])
+        [ranges addObject:r];
     }
   }
   return ranges;