Opened 3 years ago

Closed 3 years ago

#131 closed defect (fixed)

Problem with number of months in user_defined calendar

Reported by: millour Owned by: ymipsl
Priority: major Component: XIOS
Version: 2.0 Keywords: calendar
Cc:

Description

In date.cpp, the function

void CDate::addMonth(int value)
{ Value doit être égale à 1 ou -1.

this->month += value;
if (this->month == 13) { year++; this->month = 1; }
if (this->month == 0) { year--; this->month = 12; }

}

Assumes that there are 12 months/year, which is not the case for a "user_defined" calendar.
A more generic version could be:

void CDate::addMonth(int value)
{ Value doit être égale à 1 ou -1.

const CCalendar& c = getRelCalendar();
int nbMonth = c.getYearLength() ;


this->month += value;
if (this->month == nbMonth+1) { year++; this->month = 1; }
if (this->month == 0) { year--; this->month = nbMonth; }

}

Change History (1)

comment:1 Changed 3 years ago by oabramkina

  • Resolution set to fixed
  • Status changed from new to closed

Fixed.

Note: See TracTickets for help on using tickets.