In IndianCalendar, the add operation performs like roll

Description

For Calendar instances, the difference between the roll(field,amout)
and add(field,amount) operations is documented: 'roll' wraps around, while
'add' adjust the next field. For example, 'add'ing a month repeatedly should
ultimately increase the year, while 'roll' doesn't do this.

This does not work in IndianCalendar. There, 'add'ing a month may jump backward in time.

Test case:

Actual output:

Expected output: Something like

Activity

Show:
TracBot
June 30, 2018, 11:49 PM
Trac Comment 3 by —2011-03-17T19:56:43.322Z

When the month is out of 0-11 range, it was adjusted to proper values only for 12. Also, the year was never readjusted in that case, which would result in year being incorrect.

Note that this problem doesn't appear in C++, as handleComputeMonthStart() in indiancal.cpp already have the code in place to take care of this:

// If the month is out of range, adjust it into range, and adjust the extended eyar accordingly
if (month < 0 || month > 11) {
eyear += (int32_t)ClockMath::floorDivide(month, 12, month);
}

Fixed

Assignee

Dragan Besevic

Reporter

TracBot

Components

Labels

None

Reviewer

None

Priority

medium

Time Needed

None

Fix versions