Browse Source

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

git-svn-id: trunk@3864 -
michael 19 years ago
parent
commit
85017f4139
1 changed files with 3 additions and 3 deletions
  1. 3 3
      rtl/objpas/sysutils/dati.inc

+ 3 - 3
rtl/objpas/sysutils/dati.inc

@@ -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
-   Day := 28;
+  If (Day>MonthDays[IsLeapYear(Year)][Month]) then
+    Day:=MonthDays[IsLeapYear(Year)][Month];
   result := Frac(DateTime) + DoEncodeDate(Year, Month, Day);
   result := Frac(DateTime) + DoEncodeDate(Year, Month, Day);
 end ;
 end ;