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

Fix recurrence iteration where there is a negative BYMONTHDAY rule. #530

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

darktrojan
Copy link
Collaborator

Originally bug 1789362. Calculation of the initial recurrence date is wrong where BYMONTHDAY is negative.

For example, if the rule is FREQ=MONTHLY;INTERVAL=3;BYMONTHDAY=-1 the event recurs at 2, 5, 8 etc. months instead of 3, 6, 9 etc.. I've figured out that this is because we're storing a negative day value in an ICAL.Time. When we attempt to read the value it gets normalised to the previous month because the day value is negative.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3004908279

  • 0 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 95.446%

Totals Coverage Status
Change from base Build 2932458328: 0.06%
Covered Lines: 2929
Relevant Lines: 3020

💛 - Coveralls

@coveralls
Copy link

coveralls commented Sep 7, 2022

Pull Request Test Coverage Report for Build 3012284281

  • 5 of 5 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 95.445%

Totals Coverage Status
Change from base Build 2932458328: 0.06%
Covered Lines: 2928
Relevant Lines: 3019

💛 - Coveralls

@@ -675,6 +676,28 @@ suite('recur_iterator', function() {
'2015-03-31T08:00:00'
]
});
testRRULE('FREQ=MONTHLY;INTERVAL=3;BYMONTHDAY=-1', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a glance, it's not clear to me what this test is looking for. A comment would be good, or even a failure reason if testRRULE() provides for that.

@@ -302,9 +302,13 @@ ICAL.RecurIterator = (function() {
}

} else if (this.has_by_data("BYMONTHDAY")) {
if (this.last.day < 0) {
// Attempting to access `this.last.day` will cause the date to be normalised and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the comments here, let me understand this review. 😅

@darktrojan
Copy link
Collaborator Author

I've added some comments to the individual tests. It's probably still as clear as mud.

I also moved the inner if condition out. Because it probably makes more sense there unless you happen to be reading it in the context of this patch. I should've done it originally but that's what hindsight is for.

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

Successfully merging this pull request may close these issues.

3 participants