Browse Source

* replace encodedate/time by try variants mantis 14969

git-svn-id: trunk@14110 -
marco 15 years ago
parent
commit
887d8a9d92
1 changed files with 5 additions and 2 deletions
  1. 5 2
      rtl/objpas/sysutils/dati.inc

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

@@ -469,7 +469,8 @@ begin
     if (defs.TwoDigitYearCenturyWindow > 0) and (Y < ly) then
       Inc(Y, 100);
     end;
-  Result := EncodeDate(y, m, d);
+  if not TryEncodeDate(y, m, d, result) then
+    errormsg:='Invalid date';
 end;
 
 function StrToDate(const S: PChar; Len : integer; const useformat : string; separator : char = #0): TDateTime;
@@ -600,7 +601,9 @@ begin
       if (pm=1) and ((TimeValues[0]=12)) then
         TimeValues[0]:=0;
     end;
-  result := EncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3]);
+
+  if not TryEncodeTime(TimeValues[0], TimeValues[1], TimeValues[2], TimeValues[3],result) Then
+    errormsg:='Invalid time.';
 end ;
 
 function StrToTime(const S: PChar; Len : integer; separator : char = #0): TDateTime;