apognu / gocal

ICS file parser in Golang
MIT License
78 stars 24 forks source link

Incorrect combination of EXDATE and COUNT #9

Closed guscastro closed 5 years ago

guscastro commented 5 years ago

Steps: Have a recurrent event with a count and an exception date e.g.:

DTSTART:20170108T160000Z
DTEND:20170108T170000Z
RRULE:FREQ=MONTHLY;COUNT=5
EXDATE:20170408T160000Z

Expected (according to Google Calendar): COUNT should be applied before EXDATE. E.g. result:

2017-01-08
2017-02-08
2017-03-08
2017-05-08

Actual: COUNT is applied after EXDATE: E.g. result:

2017-01-08
2017-02-08
2017-03-08
2017-05-08
2017-06-08

Would you accept a PR to fix this?

guscastro commented 5 years ago

I've had a further look and it seems like decreasing count even when the event occurrence is excluded in https://github.com/apognu/gocal/blob/master/rrule.go would do the job.

apognu commented 5 years ago

Thank you for reporting this.

I will check the behavior of several mainstream implementations to confirm what should actually happen and push a fix if mine is wrong.

Should have time to do this romorrow.

apognu commented 5 years ago

This is fixed. Please reopen if necessary.

guscastro commented 5 years ago

Thanks for the quick fix, @apognu. Does this if statement also need a similar change? Here is an example of a test case that triggers the issue there:

BEGIN:VEVENT
DTSTART:20190108T160000Z
DTEND:20190108T170000Z
RRULE:FREQ=MONTHLY;COUNT=5;BYDAY=TU
EXDATE:20190122T160000Z
END:VEVENT

Expected: 2019-01-08 2019-01-15 2019-01-29 2019-02-05

Actual: 2019-01-08 2019-01-15 2019-01-22 2019-01-29 2019-02-05