Просмотр исходного кода

Merged revisions 3864 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/trunk

........
r3864 | michael | 2006-06-14 00:23:25 +0200 (Wed, 14 Jun 2006) | 1 line

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

git-svn-id: branches/fixes_2_0@3865 -

michael 19 лет назад
Родитель
Сommit
b18cd743dc
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      rtl/objpas/sysutils/dati.inc

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

@@ -250,7 +250,7 @@ end ;
 
 function IncMonth(const DateTime: TDateTime; NumberOfMonths: integer = 1 ): TDateTime;
 var
-  Year, Month, Day: word;
+  Year, Month, Day : word;
   S : Integer;
 begin
   If NumberOfMonths>=0 then
@@ -266,8 +266,8 @@ begin
      Inc(Year, S);
    end;
   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);
 end ;