From: Loof, D. <dl...@us...> - 2005-01-19 23:31:11
|
Update of /cvsroot/pclasses/pclasses2/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10864/src Modified Files: Date.cpp Log Message: Operators consider leap years Index: Date.cpp =================================================================== RCS file: /cvsroot/pclasses/pclasses2/src/Date.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Date.cpp 19 Jan 2005 16:25:17 -0000 1.3 +++ Date.cpp 19 Jan 2005 23:31:01 -0000 1.4 @@ -174,10 +174,12 @@ Date& Date::operator+=(const TimeSpan& sp) throw() { int tmp = (int)_day + sp.days(); - while ( tmp > daysInMonth(_month, _year) ) + while ( tmp && tmp > daysInMonth(_month, _year) ) { tmp -= daysInMonth(_month, _year); - if ( _month == 12 ) + if ( _month == 2 && isInLeapYear() ) + --tmp; + else if ( _month == 12 ) { _month = 1; ++_year; @@ -203,6 +205,8 @@ --_month; tmp += daysInMonth(_month, _year); + if ( _month == 2 && isInLeapYear() ) + ++tmp; } _day = tmp; return *this; |