Skip to content

expandOccurrences can drop occurrences of MONTHLY rules with BYMONTH #31

Closed

Description

@PhilflowIO

Symptom

For FREQ=MONTHLY rules with BYMONTH, ical.js yields a year's months out of order. expandOccurrences stops at the first candidate past until and reports complete: true, so an occurrence that ical.js would yield later in that same year is silently missing. Found while building PhilflowIO/dav-mcp#110, which currently works around it by expanding one year past its window for this rule shape only.

Fix

  • expandOccurrences must not stop on the first candidate past until when the iterator is not monotonic for the rule shape (MONTHLY+BYMONTH, and any other shape where ical.js is known to be non-monotonic): continue to the end of the current period (year) before stopping, or sort within the period.
  • Never report complete: true when an occurrence could still follow.
  • Test: MONTHLY;BYMONTH=… rule where an in-range occurrence comes after an out-of-range candidate in ical.js's order; property test against an independent expansion for MONTHLY/YEARLY with BY parts.
  • Once released, dav-mcp drops its workaround.

Activity

  1. added
    bug
    on Oct 8, 2026
  2. PhilflowIO commented on Oct 8, 2026

    @PhilflowIO
    OwnerAuthor

    Widened by the review of dav-mcp#110: it is not only MONTHLY+BYMONTH. ical.js emits candidates in the ORDER OF THE BY LISTS, not ascending, e.g. DAILY;BYHOUR=17,9 (200 inversions over 400 candidates), HOURLY;INTERVAL=4;BYMINUTE=45,15. expandOccurrences breaks on the first candidate past until (dist/index.mjs:1456-1458), so an occurrence or a moved-in override behind it is dropped while the result says complete. Fix for any rule whose iteration isn't monotonic: continue to the end of the current period (or sort BY lists ascending before expanding — check that this preserves BYSETPOS semantics). Also observed (pre-existing ical.js behaviour, worth tracking): leap-day YEARLY shows on 1 March in other years; BYSETPOS ignored on YEARLY; BYWEEKNO wrong with WKST; MONTHLY+BYMONTH ignores INTERVAL.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions