Skip to content

Fix #71: Implement BYSETPOS in RecurrenceEngineV2#125

Merged
thedhanawada merged 1 commit intomasterfrom
fix/issue-71-bysetpos
Mar 20, 2026
Merged

Fix #71: Implement BYSETPOS in RecurrenceEngineV2#125
thedhanawada merged 1 commit intomasterfrom
fix/issue-71-bysetpos

Conversation

@thedhanawada
Copy link
Copy Markdown
Collaborator

Fix

Implemented BYSETPOS selection logic in getNextMonthly() (RecurrenceEngineV2.js:311-343).

The previous code was a TODO stub that only advanced the month. Now:

  1. Generates all candidate dates matching byDay rules in the target month
  2. Applies BYSETPOS indices (1-based, supports negative indices from end)
  3. Selects the first matching date

Supports patterns like:

  • FREQ=MONTHLY;BYDAY=FR;BYSETPOS=-1 (last Friday of every month)
  • FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 (last weekday of month)

Files Changed

  • core/events/RecurrenceEngineV2.js — 34 lines added, 2 removed

Fixes #71

BYSETPOS was a TODO stub that only advanced the month without selecting
from the candidate set. Now generates all matching weekday occurrences
in the month based on byDay rules, then applies BYSETPOS indices
(1-based positive from start, negative from end) to select from that
set. Supports patterns like "last Friday of every month" (BYSETPOS=-1).

Fixes #71
@thedhanawada thedhanawada merged commit 1ff3ba3 into master Mar 20, 2026
8 checks passed
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.

RecurrenceEngineV2: BYSETPOS is a TODO stub

1 participant