+ Fixed incMonth so it truncates on the number of days in the target month

git-svn-id: trunk@3864 -
This commit is contained in:
michael 2006-06-13 22:23:25 +00:00
parent dc0e8428a6
commit 85017f4139

View File

@ -263,7 +263,7 @@ end;
function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDateTime; function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDateTime;
var var
Year, Month, Day: word; Year, Month, Day : word;
S : Integer; S : Integer;
begin begin
If NumberOfMonths>=0 then If NumberOfMonths>=0 then
@ -279,8 +279,8 @@ begin
Inc(Year, S); Inc(Year, S);
end; end;
Inc(Month); { Months from 1 to 12 } Inc(Month); { Months from 1 to 12 }
if (Month = 2) and (IsLeapYear(Year)) and (Day > 28) then If (Day>MonthDays[IsLeapYear(Year)][Month]) then
Day := 28; Day:=MonthDays[IsLeapYear(Year)][Month];
result := Frac(DateTime) + DoEncodeDate(Year, Month, Day); result := Frac(DateTime) + DoEncodeDate(Year, Month, Day);
end ; end ;