From 83f5dbfe6cee7454bddc2a11bc00e5c078a61e5e Mon Sep 17 00:00:00 2001 From: "daniel.boelzle%sun.com" Date: Mon, 23 Jul 2007 14:21:23 +0000 Subject: [PATCH] Bug 386502 - dtstart is always included in recurrence set, even when it's out of the query range; r=daniel git-svn-id: svn://10.0.0.236/trunk@230652 18797224-902f-48f8-a5cc-f745e15eee43 --- .../calendar/base/src/calRecurrenceInfo.js | 65 +++++++------------ 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/mozilla/calendar/base/src/calRecurrenceInfo.js b/mozilla/calendar/base/src/calRecurrenceInfo.js index 389247d1134..f4bb9a80398 100644 --- a/mozilla/calendar/base/src/calRecurrenceInfo.js +++ b/mozilla/calendar/base/src/calRecurrenceInfo.js @@ -362,54 +362,37 @@ calRecurrenceInfo.prototype = { var startDate = this.mBaseItem.recurrenceStartDate; var dates = []; - + + function checkRange(item) { + var dtstart = item.getProperty("DTSTART"); + // tasks may have a due date set or no duration at all + var end = item.getProperty("DTEND") || item.getProperty("DUE") || dtstart; + // is the item an intersection of the range? + if ((!aRangeStart || aRangeStart.compare(end) <= 0) && + (!aRangeEnd || aRangeEnd.compare(dtstart) > 0)) { + return dtstart; + } + return null; + } + // DTSTART/DUE is always part of the (positive) expanded set: // the base item cannot be replaced by an exception; // an exception can only be defined on an item resulting from an RDATE/RRULE; // DTSTART always equals RECURRENCE-ID for items expanded from RRULE - dates.push(startDate); + var baseStart = checkRange(this.mBaseItem); + if (baseStart) { + dates.push(baseStart); + } // toss in exceptions first: if (this.mExceptions) { - this.mExceptions.forEach(function(ex) { - var dtstart = ex.item.getProperty("DTSTART"); - var dateToReturn; - if (aReturnRIDs) - dateToReturn = ex.id; - else - dateToReturn = dtstart; - // is our startdate within the range? - if ((!aRangeStart || aRangeStart.compare(dtstart) <= 0) && - (!aRangeEnd || aRangeEnd.compare(dtstart) > 0)) - { - dates.push(dateToReturn); - return; - } - - // is our end date within the range? - var name = "DTEND"; - if (ex.item instanceof Components.interfaces.calITodo) - name = "DUE"; - var dtend = ex.item.getProperty(name); - if (!dtend) - return; - - if ((!aRangeStart || aRangeStart.compare(dtend) <= 0) && - (!aRangeEnd || aRangeEnd.compare(dtend) > 0)) - { - dates.push(dateToReturn); - return; - } - - // is the range in the middle of a long event? - if (aRangeStart && aRangeEnd && - aRangeStart.compare(dtstart) >= 0 && - aRangeEnd.compare(dtend) <= 0) - { - dates.push(dateToReturn); - return; - } - }); + this.mExceptions.forEach( + function(ex) { + var dtstart = checkRange(ex.item); + if (dtstart) { + dates.push(aReturnRIDs ? ex.id : dtstart); + } + }); } // apply positive items before negative: