dmfs / lib-recur

A recurrence processor for Java
Apache License 2.0
198 stars 47 forks source link

Removing unsynchronized future startdate from instance list in RecurrenceSetIterator #66

Closed deepakbulani closed 1 year ago

deepakbulani commented 5 years ago

I had one use case related to RecurrenceSet. For my use case i am using RecurrenceSet to support recurrenceRule,exceptionRule as well exdates and i also want my unsynchronized start date(say in future) to be skipped. for past start dates i am using fast forward to current date but for future start dates if i fast forward (say by 1 second) then for rules in which start dates are synchronized with the rule their first instance is skipped. Is there a way to achieve my use case? i know RecurrenceRuleIterator now skips startdate if not synchronized with rule but i have to use RecurrenceSetIterator to iterate.Any help would be appreciated.

Making changes in RecurrenceSet.java by removing- instances.add(new RecurrenceList(new long[] { start }).getIterator(timezone, start)); will be an overhead for my application.

Will removing the line help? Maybe not since again it may skip future start dates of rrules which are synchronized with the rule.Please correct if there is some other workflow. Thanks.

deepakbulani commented 5 years ago

@dmfs Can you please specify whether it is possible to skip unsynchronized future start dates using RecurrenceSetIterator(as mentioned above) or are there some other possiblities to achieve this?

dmfs commented 5 years ago

The start instance is added by RecurrenceSet so a temporary workaround for your issue would be to go back to a version which didn't add it, like this one:

https://github.com/dmfs/lib-recur/blob/603dc0043e0d06b4c4cc2c893835054e19c35bf2/src/main/java/org/dmfs/rfc5545/recurrenceset/RecurrenceSet.java

You may also have to go back to this version of RecurrenceRuleAdapter:

https://github.com/dmfs/lib-recur/blob/603dc0043e0d06b4c4cc2c893835054e19c35bf2/src/main/java/org/dmfs/rfc5545/recurrenceset/RecurrenceRuleAdapter.java

because the current version decreases COUNT by 1if the start is not synchronized with the rule (because we count the inserted start as the first instance).

Copy both files into your project and use them instead.

I'll have to put a bit more thought into this to find a generic solution which allows all sorts of use cases without too much effort.

deepakbulani commented 5 years ago

@dmfs thanks for the reply. Yes that will be great if i am able to skip unsynchronized start dates using RecurrenceSetIterator. Please let me know when you implement this.

dmfs commented 1 year ago

I've rewritten the recurrence set iteration. You can chose whether to iterate unsynchronized start dates or not. Please check out the README.md for guidance.