Changeset 1496 for XIOS/trunk


Ignore:
Timestamp:
04/27/18 11:00:44 (6 years ago)
Author:
oabramkina
Message:

Trunk and CMIP6: bugfix in addition of a month in case of a user-defined calendar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/date.cpp

    r1105 r1496  
    235235      void CDate::addMonth(int value) 
    236236      {// Value doit être égale à 1 ou -1. 
     237 
     238        const CCalendar& c = getRelCalendar(); 
     239        int nbMonthsPerYear = c.getYearLength(); 
     240 
    237241        this->month += value; 
    238         if (this->month == 13) { year++; this->month = 1; } 
    239         if (this->month == 0)  { year--; this->month = 12; } 
     242 
     243        if (this->month == nbMonthsPerYear + 1) { year++; this->month = 1; } 
     244        if (this->month == 0)  { year--; this->month = nbMonthsPerYear; } 
     245 
    240246      } 
    241247 
Note: See TracChangeset for help on using the changeset viewer.