Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > by-pkgid > d96701ed90d60bf737e8c706be49f444 > files > 2

kdepimlibs4-4.1.2-3mdv2009.0.src.rpm

# 
# Fix a weeks value being mixed with days/time in ical duration values,
# contrary to RFC2445. Libical errors when it tries to read a duration
# containing weeks and days/time, so that a value written can't be read
# back again.
# 

Index: kcal/icalformat_p.cpp
===================================================================
--- kcal/icalformat_p.cpp	(revision 865198)
+++ kcal/icalformat_p.cpp	(revision 865199)
@@ -2220,20 +2220,27 @@
   if ( value < 0 ) {
     value = -value;
   }
+  // RFC2445 states that an ical duration value must be
+  // EITHER weeks OR days/time, not both.
   if ( duration.isDaily() ) {
-    d.weeks = value / 7;
-    d.days  = value % 7;
-    d.hours = d.minutes = d.seconds = 0;
+    if ( !( value % 7 ) ) {
+      d.weeks = value / 7;
+    } else {
+      d.days  = value;
+      d.hours = d.minutes = d.seconds = 0;
+    }
   } else {
-    d.weeks   = value / gSecondsPerWeek;
-    value    %= gSecondsPerWeek;
-    d.days    = value / gSecondsPerDay;
-    value    %= gSecondsPerDay;
-    d.hours   = value / gSecondsPerHour;
-    value    %= gSecondsPerHour;
-    d.minutes = value / gSecondsPerMinute;
-    value    %= gSecondsPerMinute;
-    d.seconds = value;
+    if ( !( value % gSecondsPerWeek ) ) {
+      d.weeks = value / gSecondsPerWeek;
+    } else {
+      d.days    = value / gSecondsPerDay;
+      value    %= gSecondsPerDay;
+      d.hours   = value / gSecondsPerHour;
+      value    %= gSecondsPerHour;
+      d.minutes = value / gSecondsPerMinute;
+      value    %= gSecondsPerMinute;
+      d.seconds = value;
+    }
   }
 
   return d;