Add RFC 5545 recurrence-rule expansion#274
Merged
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 139 |
| Duplication | 0 |
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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)→ frozenRecurrence(with or without theRRULE:prefix).occurrences(rule, dtstart, *, count=, until=, max_iter=)— yields datetimes anchored atdtstart(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/afternow(injectable clock).Supported parts:
FREQ(DAILY/WEEKLY/MONTHLY/YEARLY),INTERVAL,COUNT,UNTIL,BYDAY(incl. ordinals2MO/-1FR),BYMONTHDAY(incl. negatives),BYMONTH,BYSETPOS,WKST. Time-level parts and BYWEEKNO/BYYEARDAY are out of scope. Pure stdlib (datetime+calendar); nodateutil.Five-layer wiring
je_auto_control/utils/recurrence/__init__.py+__all__AC_rrule_occurrences,AC_rrule_next(ISO in/out)ac_rrule_occurrences,ac_rrule_nextTests & 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)Lint clean: ruff / pylint / bandit / radon (no function CC > 10).