Changeset 1496


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

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

Location:
XIOS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/date.cpp

    r1158 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; } 
    240245      } 
    241246 
  • 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.