Closed dspasojevic closed 9 months ago
This function is probably also why https://github.com/volkanunsal/postgres-rrule/issues/21 occurs; multiple values are returned by all_starts
when dtstart
has the same day of the week as dayofweek
:
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)
which then produces two series of alternating dates when feed through here.
Should this issue be closed after the merge?
Because
all_starts
restricts its search space to the end of the year containingdtstart
it may sometimes return an empty set. This leads to occurrences also being empty.e.g:
returns 0 rows, because it will not find a matching Thursday between dtstart and the end of 2029.
Changing https://github.com/volkanunsal/postgres-rrule/blob/master/src/functions/0017-all_starts.sql#L44 to search beyond
year_end
(e.g. until 12 months later, same as the subsequent generators) resolves this issue.Given that the function may already process 365 days (e.g if dtstart was on Jan 1), is it an issue to increase the number of days that are processed here?
@volkanunsal happy to raise a PR if you are still maintaining this project.