I am using google-rfc2445 library (com.google.ical) to parse RRULE.
In the test below the rrule UNTIL is set in the past (year 1999) and the dtStart is set as now. I am expecting 0 result but somehow getting 1 result which seems like the dtStart. I am dumbfounded why it is including an item out of the UNTIL bound. Is that the expected behavior?
@Test
public void testRruleExpiryInPast1() {
String rruleString = "RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=19990103T000000Z";
DateTime startDate = DateTime.now(DateTimeZone.UTC);
System.out.println("startDate timeZone =" + startDate.getZone());
try {
DateTimeIterable localDateIterable = DateTimeIteratorFactory.createDateTimeIterable(rruleString, startDate, startDate.getZone(), false);
DateTimeIterator iterator = localDateIterable.iterator();
while (iterator.hasNext()) {
DateTime next = iterator.next();
System.out.println(next);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
The above test Outputs
startDate timeZone =UTC
2022-02-06T18:52:31.000Z
Update1: according to this answer, ICAL in google calendar has extra event , it seem like the DTSTART will always be the first occurrence regardless of UNTIL being in the past or not. I find this strange. Now I have resorted to regex parsing the rrule string to determine whether there is UNTIL or not and if there is whether it is in the past. :(