]> err.no Git - scalable-opengroupware.org/commitdiff
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1343 d1b88da0-ebda-0310...
authorwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 28 Jan 2008 18:52:11 +0000 (18:52 +0000)
committerwolfgang <wolfgang@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 28 Jan 2008 18:52:11 +0000 (18:52 +0000)
SOPE/NGCards/ChangeLog
SOPE/NGCards/iCalRecurrenceRule.m

index b66b3e49db181773b8752f9b9e5ff45346679089..8fd11bd86f324b5b49aab395be4de294361f82dc 100644 (file)
@@ -1,5 +1,12 @@
 2008-01-28  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
+       * iCalRecurrenceRule.m ([iCalRecurrenceRule
+       -weekDayFromICalRepresentation:_day]): issue an error whenever the
+       day cannot be deduced. Accept days notated with a prefix.
+       ([iCalRecurrenceRule -byDayMask]): don't strip the represented
+       day, feed it directly to weekDayFromICalRepresentation: since it
+       will do the correct syntax validation.
+
        * iCalDailyRecurrenceCalculator.m ([iCalDailyRecurrenceCalculator
        -recurrenceRangesWithinCalendarDateRange:]): make use of <<
        instead of exp2 to compute the mask.
index bc4efc4cffe66e625d912145dfe2f693c3746472..97fb294da8daa76222e827a34155a5da37ca5dfe 100644 (file)
       for (count = 0; count < max; count++)
        {
          day = [days objectAtIndex: count];
-         day = [day substringFromIndex: [day length] - 2];
          mask |= [self weekDayFromICalRepresentation: day];
        }
     }
 
 - (iCalWeekDay) weekDayFromICalRepresentation: (NSString *) _day
 {
-  if ([_day length] > 1) {
-    /* be tolerant */
-    unichar c0, c1;
-    
-    c0 = [_day characterAtIndex:0];
-    if (c0 == 'm' || c0 == 'M') return iCalWeekDayMonday;
-    if (c0 == 'w' || c0 == 'W') return iCalWeekDayWednesday;
-    if (c0 == 'f' || c0 == 'F') return iCalWeekDayFriday;
-
-    c1 = [_day characterAtIndex:1];
-    if (c0 == 't' || c0 == 'T') {
-      if (c1 == 'u' || c1 == 'U') return iCalWeekDayTuesday;
-      if (c1 == 'h' || c1 == 'H') return iCalWeekDayThursday;
-    }
-    if (c0 == 's' || c0 == 'S') {
-      if (c1 == 'a' || c1 == 'A') return iCalWeekDaySaturday;
-      if (c1 == 'u' || c1 == 'U') return iCalWeekDaySunday;
+  NSString *day;
+  /* be tolerant */
+  iCalWeekDay foundDay;
+  unichar chars[2];
+
+  foundDay = 0;
+
+  if ([_day length] > 1)
+    {
+      [[_day uppercaseString] getCharacters: chars
+                             range: NSMakeRange ([day length] - 2, 2)];
+
+      switch (chars[0])
+       {
+       case 'M': foundDay = iCalWeekDayMonday;
+         break;
+       case 'W': foundDay = iCalWeekDayWednesday;
+         break;
+       case 'F': foundDay = iCalWeekDayFriday;
+         break;
+       case 'T':
+         if (chars[1] == 'U')
+           foundDay = iCalWeekDayTuesday;
+         else if (chars[1] == 'H')
+           foundDay = iCalWeekDayThursday;
+       case 'S':
+         if (chars[1] == 'A')
+           foundDay = iCalWeekDaySaturday;
+         else if (chars[1] == 'H')
+           foundDay = iCalWeekDaySunday;
+       }
     }
-  }
 
-  return -1;
+  if (!foundDay)
+    [self errorWithFormat: @"wrong weekday representation: '%@'", _day];
+
+  return foundDay;
 //   // TODO: do not raise but rather return an error value?
 //   [NSException raise:NSGenericException
 //            format:@"Incorrect weekDay '%@' specified!", _day];