]> err.no Git - sope/commitdiff
additions
authorznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Tue, 15 Feb 2005 17:03:55 +0000 (17:03 +0000)
committerznek <znek@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Tue, 15 Feb 2005 17:03:55 +0000 (17:03 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@562 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-ical/NGiCal/ChangeLog
sope-ical/NGiCal/NGiCal.xcode/project.pbxproj
sope-ical/NGiCal/Version
sope-ical/NGiCal/iCalEvent.h
sope-ical/NGiCal/iCalEvent.m
sope-ical/NGiCal/iCalRepeatableEntityObject.h
sope-ical/NGiCal/iCalRepeatableEntityObject.m

index e3febed981d34f4c2bc52600608aff86129786df..45fe292c91b397ed04950f9aaaf130eeff97ab60 100644 (file)
@@ -1,3 +1,14 @@
+2005-02-15  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * v4.5.42
+
+       * iCalRepeatableEntityObject.[hm]: added ability to properly calculate
+         the recurrence ranges within a specific calendar date range, taking
+         all possible exceptions into account.
+
+       * iCalEvent.[hm]: convenience wrapper for the new method found in
+         iCalRepeatableEntityObject.
+
 2005-02-14  Helge Hess  <helge.hess@opengroupware.org>
 
        * v4.5.41
index 33a59f72a8b7034f1a85f05dd0624baa2cb1ddda..f7365484b30ee8724a7d0006f0699795687cd41d 100644 (file)
                        );
                        buildSettings = {
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 4.5.40;
+                               DYLIB_CURRENT_VERSION = 4.5.42;
                                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.40;
+                               DYLIB_CURRENT_VERSION = 4.5.42;
                                FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
                                FRAMEWORK_VERSION = A;
                                GCC_PRECOMPILE_PREFIX_HEADER = YES;
index 50a3ce02d64779e87eb8267c6384a6085c4dcfe4..03d46ce9a32c4f20e301d4579fb8f69583c13111 100644 (file)
@@ -2,7 +2,7 @@
 
 MAJOR_VERSION=4
 MINOR_VERSION=5
-SUBMINOR_VERSION:=41
+SUBMINOR_VERSION:=42
 
 # v4.5.40 requires NGExtensions v4.5.145
 # v4.5.37 requires NGExtensions v4.5.140
index 59c2602a20223c64f63bf822a3fd7f9e769b91bd..9e07b2c5f1978957a6b01910d984442300477d8c 100644 (file)
@@ -62,6 +62,8 @@
 - (BOOL)isAllDay;
 
 - (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range;
+- (NSArray *)recurrenceRangesWithinCalendarDateRange:(NGCalendarDateRange *)_r;
+
 - (NSCalendarDate *)lastPossibleRecurrenceStartDate;
 
 /* calculating changes */
index 34217f02f23cb604d84ac8471df1d70037dca0e1..a0b71d5f193299653165f09bec806298d219581a 100644 (file)
   return NO;
 }
 
+- (NSArray *)recurrenceRangesWithinCalendarDateRange:(NGCalendarDateRange *)_r {
+  NGCalendarDateRange *fir;
+  
+  if (![self isRecurrent])
+    return nil;
+  
+  fir = [NGCalendarDateRange calendarDateRangeWithStartDate:self->startDate
+                             endDate:self->endDate];
+  return [self recurrenceRangesWithinCalendarDateRange:_r
+               firstInstanceCalendarDateRange:fir];
+}
+
 - (NSCalendarDate *)lastPossibleRecurrenceStartDate {
   NGCalendarDateRange *fir;
 
index 7fb90d6d1adc4005890949be2d21bc2d9812e600..a57c01a6abf8a3c40397f4ec37481f92ba241426 100644 (file)
@@ -58,6 +58,8 @@
 - (BOOL)isRecurrent;
 - (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range
   firstInstanceCalendarDateRange:(NGCalendarDateRange *)_fir;
+- (NSArray *)recurrenceRangesWithinCalendarDateRange:(NGCalendarDateRange *)_r
+  firstInstanceCalendarDateRange:(NGCalendarDateRange *)_fir;
 
 /* this is the outmost bound possible, not necessarily the real last date */
 - (NSCalendarDate *)lastPossibleRecurrenceStartDateUsingFirstInstanceCalendarDateRange:(NGCalendarDateRange *)_r;
index 01242e3f89ed9b953e2202cadb7d9dfb49a19edc..00f9fae7a271190b5dda0db63d16b802a43c0f94 100644 (file)
 
 /* Matching */
 
-/* ZNeK: NOTE
-   Exception dates give me a headache. I believe the test below is improper,
-   we probably really need to calculate all recurrence ranges and then
-   test whether exception dates are contained in any of the required ranges
-   and remove those which were found.
-*/
 - (BOOL)isWithinCalendarDateRange:(NGCalendarDateRange *)_range
   firstInstanceCalendarDateRange:(NGCalendarDateRange *)_fir
+{
+  NSArray *ranges;
+  
+  ranges = [self recurrenceRangesWithinCalendarDateRange:_range
+                 firstInstanceCalendarDateRange:_fir];
+  return [ranges count] > 0;
+}
+
+- (NSArray *)recurrenceRangesWithinCalendarDateRange:(NGCalendarDateRange *)_r
+  firstInstanceCalendarDateRange:(NGCalendarDateRange *)_fir
 {
   iCalRecurrenceRule       *rule;
   iCalRecurrenceCalculator *calc;
-  BOOL                     didMatch = NO;
-  unsigned                 i, count;
+  NSMutableArray           *ranges;
+  unsigned                 i, count, rCount;
 
-  count = [self->rRules count];
+  ranges = [NSMutableArray array];
+  count  = [self->rRules count];
   for (i = 0; i < count; i++) {
+    NSArray *rs;
+
     rule = [self->rRules objectAtIndex:i];
     calc = [iCalRecurrenceCalculator recurrenceCalculatorForRecurrenceRule:rule
                                      withFirstInstanceCalendarDateRange:_fir];
-    if ([calc doesRecurrWithinCalendarDateRange:_range]) {
-      didMatch = YES;
-      break;
-    }
+    rs   = [calc recurrenceRangesWithinCalendarDateRange:_r];
+    [ranges addObjectsFromArray:rs];
   }
   
-  if (!didMatch)
-    return NO;
-  
+  if (![ranges count])
+    return nil;
+
   /* test if any exceptions do match */
   count = [self->exRules count];
   for (i = 0; i < count; i++) {
-    
+    NSArray *rs;
+
     rule = [self->exRules objectAtIndex:i];
     calc = [iCalRecurrenceCalculator recurrenceCalculatorForRecurrenceRule:rule
                                      withFirstInstanceCalendarDateRange:_fir];
-    if ([calc doesRecurrWithinCalendarDateRange:_range])
-      return NO; /* exception does match, so _range is not a candidate */
+    rs   = [calc recurrenceRangesWithinCalendarDateRange:_r];
+    [ranges removeObjectsInArray:rs];
   }
 
+  if (![ranges count])
+    return nil;
+
   /* exception dates are also possible */
-  count = [self->exDates count];
+  rCount = [ranges count];
+  count  = [self->exDates count];
   for (i = 0; i < count; i++) {
-    NSCalendarDate *exDate;
-    
+    NSCalendarDate      *exDate;
+    NGCalendarDateRange *r;
+    unsigned            k;
+
     exDate = [self->exDates objectAtIndex:i];
-    /* ZNeK: is _this_ correct? */
-    if ([exDate isEqualToDate:[_range startDate]])
-      return NO;
+    for (k = 0; k < rCount; k++) {
+      r = [ranges objectAtIndex:(rCount - k) - 1];
+      if ([r containsDate:exDate]) {
+        [ranges removeObjectAtIndex:k];
+      }
+    }
   }
-  return YES;
+  return ranges;
 }
 
+
 /* this is the outmost bound possible, not necessarily the real last date */
 - (NSCalendarDate *)lastPossibleRecurrenceStartDateUsingFirstInstanceCalendarDateRange:(NGCalendarDateRange *)_r
 {