Closed Bug 334704 Opened 18 years ago Closed 18 years ago

calIDuration.addDuration doesn't work well with isNegative

Categories

(Calendar :: Internal Components, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: jminta, Assigned: mvl)

Details

Attachments

(1 file)

js> var dur1 = Components.classes["@mozilla.org/calendar/duration;1"].createInstance(Components.interfaces.calIDuration);
js> var dur2 = Components.classes["@mozilla.org/calendar/duration;1"].createInstance(Components.interfaces.calIDuration);
js> dur1.days = 8;
8
js> dur2.days = 8;
8
js> dur2.isNegative = true;
true
js> dur1.normalize();
js> dur2.normalize();
js> dur2.addDuration(dur1);
js> dur2;
-P2W2D

This is killing us in month-view performance, because we always recreate the grid.  My guess is that icalDurations may stick the negative signs on the .weeks (.days, etc) attributes, while we don't.  This would cause the observed behavior.  http://lxr.mozilla.org/mozilla/source/calendar/base/src/calDuration.cpp#249
Attached patch fix — — Splinter Review
I wonder how i managed to get this wrong...
But with the patch, it passes my testcase.
Assignee: base → mvl
Status: NEW → ASSIGNED
Attachment #219053 - Flags: first-review?(dmose)
Comment on attachment 219053 [details] [diff] [review]
fix

r=dmose
Attachment #219053 - Flags: first-review?(dmose) → first-review+
patch checked in
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: