Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RRule Yearly with BYMONTH and BYDAY parts not calculating correctly #626

Closed
kroky opened this issue Sep 1, 2023 · 5 comments
Closed

RRule Yearly with BYMONTH and BYDAY parts not calculating correctly #626

kroky opened this issue Sep 1, 2023 · 5 comments

Comments

@kroky
Copy link
Contributor

kroky commented Sep 1, 2023

The following recurring event:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject 4.5.3//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:sabre-vobject-6d8dca81-7881-4a4a-9dc2-46f9223cbd78
DTSTAMP:19700101T000000Z
CREATED:19700101T000000Z
LAST-MODIFIED:19700101T000000Z
SUMMARY:Yearly every last friday of June
PRIORITY:1
TRANSP:OPAQUE
DTSTART:20230901T120000Z
DTEND:20230901T130000Z
RRULE:FREQ=YEARLY;BYMONTH=6;BYDAY=-1FR;UNTIL=20280901T000000Z
END:VEVENT
END:VCALENDAR

Starts Sep 1 and should recur every year last Friday of June but first recurrence falls on Fri, Sep 29 and then next ones are in June next years.

It seems the code at https://github.com/sabre-io/vobject/blob/master/lib/Recur/RRuleIterator.php#L612 bypasses BYMONTH checks for next yearly recurrence if the current day of month is less than the recurring one. Shouldn't we always check if the next recurrences happen on the specified BYMONTH no matter what or am I misunderstanding RFC5545?

@marclaporte
Copy link

@phil-davis we have seen another similar issue. Can you advise on this one before we take the next step?

Thanks!

@phil-davis
Copy link
Contributor

https://datatracker.ietf.org/doc/html/rfc5545
Section 3.8.5.1 Exception Date-Times

The "DTSTART" property
      defines the first instance in the recurrence set.  The "DTSTART"
      property value SHOULD match the pattern of the recurrence rule, if
      specified.  The recurrence set generated with a "DTSTART" property
      value that doesn't match the pattern of the rule is undefined.

So the RFC expects that an event has a DTSTART specified that actually is a "valid" event date-time that the RRULE filter would generate.

The existing sabre-io/vobject code is more flexible than that. It allows DTSTART to be "whatever date" and usually finds and schedules the first occurrence of the event on the first date on or after that, which the RRULE filter will allow.

So this example is a bug - sometimes there may be no occurrences of an event from the DTSTART through to the end of the start year. The code should not return some date in the DTSTART year that does not match the RRULE. The code should be returning the first occurrence as the first date in the next year that matches the RRULE.

If someone has a proposed fix, please make a PR with unit test cases and code to make them pass.

@kroky
Copy link
Contributor Author

kroky commented May 14, 2024

PR ready for your review.

@phil-davis
Copy link
Contributor

Fixed by #656 - thanks

@phil-davis
Copy link
Contributor

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

No branches or pull requests

3 participants