0

I experience an unexpected behaviour when creating a recurrence rule in ical4j(3.2.3).

I am quite new to ical4j but I have already looked into https://www.rfc-editor.org/rfc/rfc5545#section-3.3.10, which was quoted in another question here: https://stackoverflow.com/a/7800560/19390104. I can't find a solution, though.

The aim is to create one meeting per month on a specific weekday. The first date should be the next according weekday and the next date one month later.

Let me give an easy example:

Start Date: 06-22-2022. Weekday: Wednesday. The meeting should be monthly repeated for 3 times.

The expected outcome would be: [06-22-2022, 07-20-2022, 08-17-2022].

To achieve this, I tried the following recurrence rule: "FREQ=MONTHLY;BYDAY=WE;COUNT=3"

The actual outcome looks the following: [06-22-2022, 06-29-2022, 07-06-2022]. So it seems that the monthly frequency is actually ignored and the recurrence is based on a weekly frequency, when the BYDAY recur rule is used.

Can somebody help me and tell me, why the monthly frequency is ignored and how I should design a recurrence rule which works for the desired use case?


Update: I got the correct result by using a weekly frequency, every 4 weeks.

Could it be, that the monthly recurrence on a weekday does only work, when a specific week is defined? So that ical4j knowns, in which week the monthly pattern should be repeated?

For example: "FREQ=MONTHLY;BYDAY=4WE;COUNT=3" for every 4th wednesday in the month (which returns a different result that just counting the amount of weeks from the first date, though)?

Lenny
  • 1
  • 1

1 Answers1

0

I think the issue is that COUNT doesn't work how you expect for FREQ=MONTHLY. There is a table in the rfc section you shared that dictates whether occurrences are limited (reduced) or expanded (replicated). For this combination COUNT will expand the monthly day to three monthly days.

So I think for the first Wednesday of the month you might try:

FREQ=MONTHLY;BYDAY=1WE

or the last Wednesday of the month:

FREQ=MONTHLY;BYDAY=-1WE

To limit the occurrences you can use UNTIL or specify a DTEND property.

fortuna
  • 701
  • 5
  • 7