dmfs/lib-recur

FastForwarded still includes earlier RDATEs if fastForwardTo ≤ DTSTART

Closed this issue · 2 comments

I believe there's a bug in the way FastForwarded handles RDATES. It could potentially be related to #67, but I'm not sure.

Steps to reproduce

  1. Define FastForwarded Composite of
    • InstanceList of RDATEs, e.g. [2023-07-15, 2023-08-15]
    • RuleInstances of some RecurrenceRule, e.g. FREQ=MONTHLY;BYMONTHDAY=10;
    • fastForwardTo after an RDATE, e.g. 2023-08-01
  2. Define RecurrenceSet of the above with first after or equal to fastForwardTo, e.g. 2023-08-01 or 2023-08-02

Observed behaviour

The RecurrenceSet iteration starts with the RDATE prior to fastForwardTo, then occurrences from the fast forwarded rule instances, i.e.

  • 2023-07-15
  • 2023-08-10
  • 2023-08-15
  • 2023-09-10
  • 2023-10-10
  • ...

Expected behaviour

The RecurrenceSet fast forwards past the RDATEs, and iteration starts with the first occurrence after fastForwardTo, i.e.

  • 2023-08-10
  • 2023-08-15
  • 2023-09-10
  • 2023-10-10
  • ...

If instead fastForwardTo is strictly after first by one day, the expected behaviour is observed.

Notes

  • All the DateTimes I'm using are instantiated using the DateTime(int year, int month, int dayOfMonth) constructor (where month is 0-indexed).
  • I'm calling the lib from Clojure, but it should be functionally equivalent to something like this in Java:
    RecurrenceRule rrule = new RecurrenceRule(Freq.MONTHLY);
    rrule.setByPart(Part.BYMONTHDAY, 10);
    
    long[] rdates = new long[] {1689379200000, 1692057600000}; // 2023-07-15, 2023-08-15
    
    for (DateTime instance:
         new RecurrenceSet(new DateTime(2023, 7, 1), // 2023-08-01
                           new FastForwarded(new DateTime(2023, 7, 1), // 2023-08-01
                                             new Composite(new InstanceList(rdates),
                                                           new RuleInstances(rrule))))) {
        // first element is 2023-07-15
    }

Thanks for the detailed report. Looks indeed like a bug. I'll take care of that.

fixed in 1.15.1