Skip to content

fix(rrule): restore before/after compatibility mapping#500

Merged
jens-maus merged 1 commit into
jens-maus:masterfrom
KristjanESPERANTO:before-after
May 2, 2026
Merged

fix(rrule): restore before/after compatibility mapping#500
jens-maus merged 1 commit into
jens-maus:masterfrom
KristjanESPERANTO:before-after

Conversation

@KristjanESPERANTO
Copy link
Copy Markdown
Contributor

@KristjanESPERANTO KristjanESPERANTO commented Apr 29, 2026

Map wrapper methods to rrule-temporal API:

  • before() -> previous()
  • after() -> next()

That should have happened during the migration from rrule to rrule-temporal (#422).

I also added a regression test to ensure event.rrule.before()/after() work and return the expected Date values without throwing.

Fixes #499.

Summary by CodeRabbit

  • Bug Fixes

    • RRULE before() and after() methods now correctly identify preceding and following occurrences in recurrence patterns.
  • Tests

    • Added test verifying RRULE API compatibility with recurring events containing occurrence limits.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@KristjanESPERANTO has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 45 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 46e9e946-401d-400e-80af-2cae9b59b7b9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f48db0 and 91ffd6e.

📒 Files selected for processing (2)
  • ical.js
  • test/basic.test.js
📝 Walkthrough

Walkthrough

The changes fix a compatibility issue in RRuleCompatWrapper where before() and after() methods now correctly delegate to rrule-temporal's previous() and next() APIs respectively. A new unit test validates this RRULE API compatibility with both methods.

Changes

Cohort / File(s) Summary
API Delegation Fix
ical.js
Updated RRuleCompatWrapper.before() and RRuleCompatWrapper.after() to call previous() and next() respectively on the underlying rrule-temporal instance, maintaining conditional Date conversion.
Test Coverage
test/basic.test.js
Added unit test verifying RRULE API compatibility by exercising before(date, inclusive) and after(date, inclusive) on a parsed VEVENT with daily RRULE, asserting correct Date return types and expected UTC timestamps.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #422: Introduced the original RRuleCompatWrapper class and its Temporal↔Date handling logic that this PR now corrects.
  • PR #433: Previously reworked the rrule-temporal integration and wrapper behavior, establishing the foundation for this method delegation fix.
  • PR #453: Updated rrule-temporal dependency and removed an RRULE UNTIL workaround, directly related to the rrule-temporal API integration being corrected here.

Poem

🐰 Before and after, now they call the right way,
Previous and next, no more API fray,
Date conversions dance, conditional and true,
Tests verify all—our wrapper's brand new!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(rrule): restore before/after compatibility mapping' accurately describes the main change: restoring before/after method compatibility by mapping them to the new rrule-temporal API methods.
Linked Issues check ✅ Passed The PR successfully implements the requirements from issue #499 by updating RRuleCompatWrapper.before() and after() methods to delegate to rrule-temporal's previous() and next() APIs, restoring the expected API compatibility.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the before/after compatibility issue: the ical.js method delegation updates and the test/basic.test.js regression test align with the issue requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 18 minutes and 45 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/basic.test.js (1)

304-310: Optional: add boundary/inclusive edge-case assertions for stronger contract coverage.

This would lock behavior for inclusive=true and no-match boundaries (undefined) as part of the same regression scenario.

Suggested test additions
       const beforeDate = event.rrule.before(new Date('2023-01-03T09:00:00.000Z'), false);
       const afterDate = event.rrule.after(new Date('2023-01-03T09:00:00.000Z'), false);
+      const beforeInclusive = event.rrule.before(new Date('2023-01-03T09:00:00.000Z'), true);
+      const afterInclusive = event.rrule.after(new Date('2023-01-03T09:00:00.000Z'), true);
+      const beforeBoundary = event.rrule.before(new Date('2023-01-01T09:00:00.000Z'), false);
+      const afterBoundary = event.rrule.after(new Date('2023-01-05T09:00:00.000Z'), false);

       assert_.ok(beforeDate instanceof Date, 'rrule.before() should return a Date');
       assert_.ok(afterDate instanceof Date, 'rrule.after() should return a Date');
       assert_.equal(beforeDate.toISOString(), '2023-01-02T09:00:00.000Z');
       assert_.equal(afterDate.toISOString(), '2023-01-04T09:00:00.000Z');
+      assert_.equal(beforeInclusive?.toISOString(), '2023-01-03T09:00:00.000Z');
+      assert_.equal(afterInclusive?.toISOString(), '2023-01-03T09:00:00.000Z');
+      assert_.equal(beforeBoundary, undefined);
+      assert_.equal(afterBoundary, undefined);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/basic.test.js` around lines 304 - 310, Add assertions around the
inclusive boundary and no-match cases for event.rrule.before and
event.rrule.after: call event.rrule.before(..., true) and event.rrule.after(...,
true) to assert that when inclusive=true and the input equals an occurrence you
get that exact Date, and add assertions that calling before/after with a date
outside the recurrence range returns undefined (or falsy) to lock the no-match
behavior; reference the existing event.rrule.before and event.rrule.after calls
and mirror their toISOString checks to validate the inclusive returns and
undefined responses.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/basic.test.js`:
- Around line 304-310: Add assertions around the inclusive boundary and no-match
cases for event.rrule.before and event.rrule.after: call event.rrule.before(...,
true) and event.rrule.after(..., true) to assert that when inclusive=true and
the input equals an occurrence you get that exact Date, and add assertions that
calling before/after with a date outside the recurrence range returns undefined
(or falsy) to lock the no-match behavior; reference the existing
event.rrule.before and event.rrule.after calls and mirror their toISOString
checks to validate the inclusive returns and undefined responses.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 972c8308-0e63-43ff-9bac-6a061fe4b575

📥 Commits

Reviewing files that changed from the base of the PR and between 09eba0a and 9f48db0.

📒 Files selected for processing (2)
  • ical.js
  • test/basic.test.js

Map wrapper methods to rrule-temporal API:
- before() -> previous()
- after() -> next()

Add regression test to ensure event.rrule.before()/after() work and return the expected Date values without throwing.
@KristjanESPERANTO
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KristjanESPERANTO
Copy link
Copy Markdown
Contributor Author

@jens-maus coderabbit seems satisfied. Did you noticed this PR? 🙂

@jens-maus jens-maus merged commit 73acc2d into jens-maus:master May 2, 2026
14 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the before-after branch May 2, 2026 15:30
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.

TypeError: this._rrule.before is not a function in v0.26.0

2 participants