Patch level : 2.2

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Corretta add_month in modo da supportare anche i mesi negativi


git-svn-id: svn://10.65.10.50/trunk@12977 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-04-21 14:46:05 +00:00
parent c767ffd46b
commit 8b7f5b0b56

View File

@ -412,14 +412,24 @@ void TDate::get_week_year(int &weekd, int &yeard, bool complete)
void TDate::addmonth(int nmonth)
{
const int wday = day();
int wday = day();
int wyear = year();
int wmonth = month() + nmonth;
while (wmonth > 12)
{
wmonth -= 12;
wyear++;
}
while (wmonth <= 0)
{
wmonth += 12;
wyear--;
}
const int last = last_day(wmonth, wyear);
if (wday > last)
wday = last;
_val = makedata(wday, wmonth, wyear);
}