Changeset 423


Ignore:
Timestamp:
02/25/13 01:15:54 (11 years ago)
Author:
ymipsl
Message:

Bug fix in calendar

YM

Location:
XIOS/trunk/src
Files:
3 edited

Legend:

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

    r343 r423  
    7070 
    7171         // Ajustement des mois en fonction des jours. 
    72          int signVal = (drr.day != 0) ? drr.day/fabs(drr.day) : 0; 
    7372         CDate dtt(dt);  
    74          if (signVal < 0) dtt.addMonth (signVal); 
     73         drr.day+=dtt.getDay()-1 ; 
     74         dtt.setDay(1) ;          
    7575 
    76          for(; c.getMonthLength(dtt) < fabs(drr.day); dtt.addMonth (signVal)) 
    77          { drr.day -= signVal * c.getMonthLength(dtt); drr.month += signVal; } 
     76         if ( drr.day >= 0 ) 
     77         { 
     78           for(; c.getMonthLength(dtt) <= drr.day; dtt.addMonth (1)) 
     79           { drr.day -=  c.getMonthLength(dtt); drr.month += 1 ; } 
    7880 
    79          day += dt.getDay() + drr.day; 
     81           day = drr.day+1 ; 
     82         } 
     83         else  
     84         { 
     85           dtt.addMonth(-1) ; 
     86           for(; c.getMonthLength(dtt) < -drr.day; dtt.addMonth (-1)) 
     87           { drr.day+=c.getMonthLength(dtt) ; drr.month-=1 ; } 
     88           day=c.getMonthLength(dtt)+drr.day+1 ; 
     89         } 
     90             
     91/* 
    8092         if (day <  0) { drr.month --; day += c.getMonthLength(dtt); } 
    81          if (day >= c.getMonthLength(dtt)) { drr.month ++; day -= c.getMonthLength(dtt); } // << ProblÚme ici 
     93         if (day > c.getMonthLength(dtt)) { drr.month ++; day -= c.getMonthLength(dtt); } // << ProblÚme ici 
    8294         if (day == 0){ day = c.getMonthLength(dtt); drr.month --; } 
    83           
     95*/          
    8496         drr.resolve(dt.getRelCalendar()); 
    8597 
  • XIOS/trunk/src/date.cpp

    r343 r423  
    177177      void CDate::setYear  (int newyear)  { this->year  = newyear; } 
    178178      void CDate::setMonth (int newmonth) { this->month = newmonth; } 
     179      void CDate::setDay (int newday) { this->day = newday; } 
    179180 
    180181      //---------------------------------------------------------------- 
  • XIOS/trunk/src/date.hpp

    r343 r423  
    5050            void setYear  (int newyear); 
    5151            void setMonth (int newmonth); 
     52            void setDay (int newday); 
    5253 
    5354            void addMonth (int value); 
Note: See TracChangeset for help on using the changeset viewer.