1

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. :(

TCh
  • 11
  • 2
  • I have only seen the ISO format `UNTIL=1999-01-03T00:00:00Z`, but no experience. – Joop Eggen Feb 06 '22 at 19:13
  • 1
    @JoopEggen , I retried with `RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=1999-01-03T00:00:00Z` but I got `java.text.ParseException` . – TCh Feb 06 '22 at 19:53

1 Answers1

0

Your use case is a little bit of a logical corner case.

Technically the RFC2245 in the section section-4.3.10 says:

The "DTSTART" property value, if specified, counts as the first occurrence.

The underlying logic being that the first instance is specified by DTSTART and that subsequent instances should be derived from the RRULE.

In your case since you are specifying UNTIL before DTSTART we are to the best of my knowledge in a grey area where the RFC does not specify how the RRULE instances should be generated.

I suspect that the Google library is sticking to the letter of the RFC and pre-pending DTSART to the list of instances without checking if it before the date specified by UNTIL since RFC does not mention this.

Auberon Vacher
  • 4,655
  • 1
  • 24
  • 36