Skip to content

Add RFC 5545 recurrence-rule expansion#274

Merged
JE-Chen merged 1 commit into
devfrom
feat/recurrence
Jun 20, 2026
Merged

Add RFC 5545 recurrence-rule expansion#274
JE-Chen merged 1 commit into
devfrom
feat/recurrence

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

The scheduler's cron is interval-style 5-field only — it cannot express "every 2nd Tuesday", "the last weekday of the month", or "every weekday for 10 occurrences". This adds an RFC 5545 (iCalendar) RRULE parser and occurrence expander, the calendar layer above cron.

  • parse_rrule(text) → frozen Recurrence (with or without the RRULE: prefix).
  • occurrences(rule, dtstart, *, count=, until=, max_iter=) — yields datetimes anchored at dtstart (its time/tz applied), bounded by COUNT/UNTIL (a date-only UNTIL is inclusive of the whole day).
  • next_occurrence(rule, dtstart, *, now=) — first occurrence at/after now (injectable clock).

Supported parts: FREQ (DAILY/WEEKLY/MONTHLY/YEARLY), INTERVAL, COUNT, UNTIL, BYDAY (incl. ordinals 2MO/-1FR), BYMONTHDAY (incl. negatives), BYMONTH, BYSETPOS, WKST. Time-level parts and BYWEEKNO/BYYEARDAY are out of scope. Pure stdlib (datetime+calendar); no dateutil.

Five-layer wiring

  • Headless core: je_auto_control/utils/recurrence/
  • Facade: re-exported from __init__.py + __all__
  • Executor: AC_rrule_occurrences, AC_rrule_next (ISO in/out)
  • MCP: ac_rrule_occurrences, ac_rrule_next
  • Script Builder: "Recurrence: Expand (RRULE)" / "Recurrence: Next Occurrence" under Flow

Tests & docs

  • test/unit_test/headless/test_recurrence_batch.py (15 tests: 2nd Tuesday, last weekday via BYSETPOS, negative BYMONTHDAY, BYMONTH multi-month, UNTIL inclusivity, next-occurrence)
  • v66 feature docs (EN + Zh) + toctree registration
  • What's-new sections in all three READMEs

Lint clean: ruff / pylint / bandit / radon (no function CC > 10).

The scheduler's cron is interval-style 5-field only and cannot express
calendar rules like every 2nd Tuesday or the last weekday of the month.
Add an RRULE parser and occurrence expander supporting FREQ/INTERVAL/
COUNT/UNTIL/BYDAY (with ordinals)/BYMONTHDAY/BYMONTH/BYSETPOS/WKST, with
an injectable clock so next_occurrence is deterministic. Wired through the
facade, AC_rrule_occurrences and AC_rrule_next executor commands, MCP
tools and the Script Builder.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 139 complexity · 0 duplication

Metric Results
Complexity 139
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 99c7085 into dev Jun 20, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/recurrence branch June 20, 2026 23:37
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant