Răsfoiți Sursa

* Fix strtodate for dates between 1 and 100 AD

git-svn-id: trunk@5658 -
joost 18 ani în urmă
părinte
comite
27213c6873
1 a modificat fișierele cu 5 adăugiri și 1 ștergeri
  1. 5 1
      rtl/objpas/sysutils/dati.inc

+ 5 - 1
rtl/objpas/sysutils/dati.inc

@@ -327,7 +327,9 @@ var
    s1:string[4];
    values:array[1..3] of longint;
    LocalTime:tsystemtime;
+   YearMoreThenTwoDigits : boolean;
 begin
+  YearMoreThenTwoDigits := False;
   df := UpperCase(ShortDateFormat);
   { Determine order of D,M,Y }
   yp:=0;
@@ -375,6 +377,8 @@ begin
         inc(n);
         if n>3 then
          Raise EConvertError.Create('Invalid date format');
+         // Check if the year has more then two digits (if n=yp, then we are evaluating the year.)
+        if (n=yp) and (length(s1)>2) then YearMoreThenTwoDigits := True;
         val(s1, values[n], c);
         if c<>0 then
          Raise EConvertError.Create('Invalid date format');
@@ -412,7 +416,7 @@ begin
         m:=values[1];
       end;
   end;
-  if (y >= 0) and (y < 100) then
+  if (y >= 0) and (y < 100) and not YearMoreThenTwoDigits then
     begin
     ly := ly - TwoDigitYearCenturyWindow;
     Inc(Y, ly div 100 * 100);