浏览代码

* replace encodedate/time by try variants mantis 14969

git-svn-id: trunk@14110 -
marco 16 年之前
父节点
当前提交
887d8a9d92
共有 1 个文件被更改,包括 5 次插入2 次删除
  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;