there are other bugs in that class as well. GetNextOccurrence incorrectly returns true and OccurrenceStart set outside [VisibleStart;VisibleFinish] range since IsValidOccurrence method is also broken, see comments below
function TcxSchedulerOccurrenceCalculator.IsValidOccurrence: Boolean;
Result := ((FRecurCount >= 0) and (FIndex < FRecurCount)) or // if FRecurCount>=0 it doesn't take into account FinishDate and incorrectly returns true (according to FIndex check) for OccurrenceStart>VisibleFinish as it happens in my project
((FRecurCount < 0) and
((DateOf(FOccurrenceStart) <= FFinishDate) or
(FCalcForReminders and (DateOf(FOccurrenceStart) - 14 <= FFinishDate))));
I believe in fact there's not much to discuss, it should work as described in help, it should always respect assigned datetime range passed in constructor. and no, I do not have small demo, it happens in my real app which is rather huge. I can't believe you don't see described problem in your own internal tests. I added "and (DateOf(FOccurrenceStart) <= FFinishDate)" to the first part of conditional check in IsValidOccurrence in order to always check for FinishDate and quick tests worked ok but I'm not sure yet how it may influence upon internal scheduler logic since that class is used everywhere. since you obviously have deeper insight in scheduler internals you should make adequate decision whether it's ok or not
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.