From kde-pim Sun May 28 22:53:18 2006 From: David Jarvie Date: Sun, 28 May 2006 22:53:18 +0000 To: kde-pim Subject: [Kde-pim] [PATCH] libkcal 3.5 branch Message-Id: <200605282353.19106.lists () astrojar ! org ! uk> X-MARC-Message: https://marc.info/?l=kde-pim&m=114885686005749 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_fnieE/rl/CIYzGp" --Boundary-00=_fnieE/rl/CIYzGp Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline I've noticed that for a recurring event, the CalendarLocal::alarmsTo() method returns alarms starting in the year 1900, regardless of the start date of the event. This is due to a bug in the appendRecurringAlarms() method. I attach a patch to fix this - the patch applies equally to 3.5 branch and to trunk. OK to commit? -- David Jarvie. KAlarm author and maintainer. http://www.astrojar.org.uk/linux/kalarm.html --Boundary-00=_fnieE/rl/CIYzGp Content-Type: text/x-diff; charset="us-ascii"; name="cl.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cl.diff" Index: calendarlocal.cpp =================================================================== --- calendarlocal.cpp (revision 546062) +++ calendarlocal.cpp (working copy) @@ -309,8 +309,14 @@ offset = alarm->endOffset().asSeconds() + endOffset; } - // Adjust the 'from' date/time and find the next recurrence at or after it - qdt = incidence->recurrence()->getNextDateTime( from.addSecs(-offset - 1) ); + // Find the incidence's earliest alarm + QDateTime fromStart = incidence->dtStart().addSecs( offset ); + if ( fromStart > to ) + continue; + if ( from > fromStart ) + fromStart = from; // don't look earlier than the earliest alarm + // Adjust the 'fromStart' date/time and find the next recurrence at or after it + qdt = incidence->recurrence()->getNextDateTime( fromStart.addSecs(-offset - 1) ); if ( !qdt.isValid() || (qdt = qdt.addSecs( offset )) > to ) // remove the adjustment to get the alarm time { @@ -320,13 +326,13 @@ // The alarm has repetitions, so check whether repetitions of previous // recurrences fall within the time period. bool found = false; - qdt = from.addSecs( -offset ); + qdt = fromStart.addSecs( -offset ); while ( (qdt = incidence->recurrence()->getPreviousDateTime( qdt )).isValid() ) { - int toFrom = qdt.secsTo( from ) - offset; + int toFrom = qdt.secsTo( fromStart ) - offset; if ( toFrom > alarm->duration() ) break; // this recurrence's last repetition is too early, so give up - // The last repetition of this recurrence is at or after 'from' time. - // Check if a repetition occurs between 'from' and 'to'. + // The last repetition of this recurrence is at or after 'fromStart' time. + // Check if a repetition occurs between 'fromStart' and 'to'. int snooze = alarm->snoozeTime() * 60; // in seconds if ( period >= snooze || toFrom % snooze == 0 --Boundary-00=_fnieE/rl/CIYzGp Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kde-pim mailing list kde-pim@kde.org https://mail.kde.org/mailman/listinfo/kde-pim kde-pim home page at http://pim.kde.org/ --Boundary-00=_fnieE/rl/CIYzGp--