Skip to content

Implement BYSETPOS support for monthly recurrence rules with BYMONTHDAY#985

Open
mschroeder wants to merge 1 commit into
kewisch:mainfrom
mschroeder:rrule-monthly-bymonthday-bysetpos
Open

Implement BYSETPOS support for monthly recurrence rules with BYMONTHDAY#985
mschroeder wants to merge 1 commit into
kewisch:mainfrom
mschroeder:rrule-monthly-bymonthday-bysetpos

Conversation

@mschroeder

Copy link
Copy Markdown
Collaborator

Fixes #960

@mschroeder mschroeder self-assigned this May 28, 2026

@kewisch kewisch left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spectacular, thanks for tackling this Martin. Good to see you're still following :)

Some minor comments if you could take a look

let day = this._findByMonthDaySetPos(this.last.day + 1);
let attempts = 0;

while (!day && attempts++ < 48) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment on why 48 attempts, here and in the last function?

Comment on lines +808 to +810
if (this.has_by_data("BYSETPOS")) {
data_valid = this._nextMonthlyByMonthDaySetPos();
} else {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered cases where we have BYMONTHDAY, BYSETPOS, and other rule parts? I think theoretically a BYDAY could appears as well.

@hiSandog

Copy link
Copy Markdown

The BYMONTHDAY/BYSETPOS coverage is strong, especially the negative and invalid-position cases. One edge worth considering is interaction with BYDAY, because RFC expansion normally filters the candidate set before applying BYSETPOS. A test like monthly BYMONTHDAY=1,2,3,4,5;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 would make sure the selected position is based on the fully filtered monthly candidate list, not only the normalized month days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug in BYSETPOS

3 participants