mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-21 11:49:20 +02:00
* fixed StrToDate to throw proper exceptions in case of an error, fixes bug #3913
git-svn-id: trunk@156 -
This commit is contained in:
parent
a39fd9d2ea
commit
4f30642b4a
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6112,6 +6112,7 @@ tests/webtbs/tw3893.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw3898.pp svneol=native#text/plain
|
tests/webtbs/tw3898.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3899.pp svneol=native#text/plain
|
tests/webtbs/tw3899.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3900.pp svneol=native#text/plain
|
tests/webtbs/tw3900.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw3913.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3939.pp svneol=native#text/plain
|
tests/webtbs/tw3939.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3953a.pp svneol=native#text/plain
|
tests/webtbs/tw3953a.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw3953b.pp svneol=native#text/plain
|
tests/webtbs/tw3953b.pp svneol=native#text/plain
|
||||||
|
@ -369,7 +369,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
if (s[i] in ['0'..'9']) then
|
if (s[i] in ['0'..'9']) then
|
||||||
s1 := s1 + s[i];
|
s1 := s1 + s[i];
|
||||||
if (s[i] in [dateseparator,' ']) or (i = length(s)) then
|
if (s[i] in [dateseparator,' ']) or ((i = length(s)) and (s[i] in ['0'..'9'])) then
|
||||||
begin
|
begin
|
||||||
inc(n);
|
inc(n);
|
||||||
if n>3 then
|
if n>3 then
|
||||||
@ -378,7 +378,9 @@ begin
|
|||||||
if c<>0 then
|
if c<>0 then
|
||||||
Raise EConvertError.Create('Invalid date format');
|
Raise EConvertError.Create('Invalid date format');
|
||||||
s1 := '';
|
s1 := '';
|
||||||
end ;
|
end
|
||||||
|
else if not (s[i] in ['0'..'9']) then
|
||||||
|
Raise EConvertError.Create('Invalid date format');
|
||||||
end ;
|
end ;
|
||||||
// Fill in values.
|
// Fill in values.
|
||||||
getLocalTime(LocalTime);
|
getLocalTime(LocalTime);
|
||||||
@ -416,7 +418,7 @@ begin
|
|||||||
if (TwoDigitYearCenturyWindow > 0) and (Y < ly) then
|
if (TwoDigitYearCenturyWindow > 0) and (Y < ly) then
|
||||||
Inc(Y, 100);
|
Inc(Y, 100);
|
||||||
end;
|
end;
|
||||||
Result := DoEncodeDate(y, m, d);
|
Result := EncodeDate(y, m, d);
|
||||||
end ;
|
end ;
|
||||||
|
|
||||||
|
|
||||||
|
25
tests/webtbs/tw3913.pp
Normal file
25
tests/webtbs/tw3913.pp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{ $mode objfpc}
|
||||||
|
uses
|
||||||
|
sysutils;
|
||||||
|
var
|
||||||
|
d : tdatetime;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
d:=strtodate('03'+dateseparator+'03'+dateseparator+'2033');
|
||||||
|
except
|
||||||
|
halt(1);
|
||||||
|
end;
|
||||||
|
writeln(1);
|
||||||
|
try
|
||||||
|
d:=strtodate('2.2/2');
|
||||||
|
halt(1);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
writeln(2);
|
||||||
|
try
|
||||||
|
d:=strtodate('33'+dateseparator+'33'+dateseparator+'33');
|
||||||
|
halt(1);
|
||||||
|
except
|
||||||
|
end;
|
||||||
|
writeln('ok');
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user