Closed dspasojevic closed 9 months ago
I don't think it is just that the interval
is ignored.
When byday
is Wednesday:
postgres=# select occurrences('{"freq": "WEEKLY", "wkst": "MO", "byday": ["WE"], "until": "2023-08-01", "interval": 2}'::jsonb::rrule, '2023-06-19');
occurrences
---------------------
2023-06-21 00:00:00
2023-07-05 00:00:00
2023-07-19 00:00:00
(3 rows)
When byday
is Monday but the start date is set to the day before the first occurrence:
postgres=# select occurrences('{"freq": "WEEKLY", "wkst": "MO", "byday": ["MO"], "until": "2023-08-01", "interval": 2}'::jsonb::rrule, '2023-06-18');
occurrences
---------------------
2023-06-19 00:00:00
2023-07-03 00:00:00
2023-07-17 00:00:00
2023-07-31 00:00:00
(4 rows)
As noted in #22, the root cause of this seems to be this fragment of all_starts
:
SELECT "ts" FROM (
SELECT "ts"
FROM generate_series("dtstart", year_end, INTERVAL '1 day') "ts"
WHERE (
"ts"::_rrule.DAY = ANY("rrule"."byday")
)
AND "ts" <= ("dtstart" + INTERVAL '7 days')
) as "ts"
that will produce two starts
when byday
is the same day of the week as dtstart:
postgres=# select * from all_starts('RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;COUNT=100'::text::rrule, '2023-07-04T10:00:00'::TIMESTAMP);
all_starts
---------------------
2023-07-04 10:00:00
2023-07-11 10:00:00
(2 rows)
It isn't clear to me why AND "ts" <= ("dtstart" + INTERVAL '7 days')
is used instead of AND "ts" < ("dtstart" + INTERVAL '7 days')
.
Are there circumstances in which it is necessary to include the seventh day?
This issue should too be closed after the merge?
When creating a rule to repeat every other Monday, rrule seems to suggest a rule like:
Interval works as I would expect when
byday
is not set:However, when
byday
is set, interval appears to be ignored:Do you expect
byday
andinterval
to work together?