You've already forked lazarus-ccr
xsd_TryStrToDate : do not reject if fractional milisecond part contains more than 3 digits
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1116 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -278,6 +278,12 @@ var
|
|||||||
Inc(bufferPos);
|
Inc(bufferPos);
|
||||||
Inc(locDigitCount);
|
Inc(locDigitCount);
|
||||||
end;
|
end;
|
||||||
|
if ( locDigitCount >= 3 ) then begin
|
||||||
|
//Skip the remaining fractional part
|
||||||
|
while ( bufferPos <= bufferLen ) and ( buffer[bufferPos] in ['0'..'9'] ) do begin
|
||||||
|
Inc(bufferPos);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
Result := ( locDigitCount > 0 );
|
Result := ( locDigitCount > 0 );
|
||||||
if Result then begin
|
if Result then begin
|
||||||
if ( locDigitCount < 3 ) and ( locRes > 0 ) then begin
|
if ( locDigitCount < 3 ) and ( locRes > 0 ) then begin
|
||||||
|
@@ -40,6 +40,7 @@ type
|
|||||||
procedure xsd_TryStrToDate_date_timezone_2();
|
procedure xsd_TryStrToDate_date_timezone_2();
|
||||||
procedure xsd_TryStrToDate_date_time();
|
procedure xsd_TryStrToDate_date_time();
|
||||||
procedure xsd_TryStrToDate_date_time_fractional_second();
|
procedure xsd_TryStrToDate_date_time_fractional_second();
|
||||||
|
procedure xsd_TryStrToDate_date_time_fractional_second_2();
|
||||||
procedure xsd_TryStrToDate_date_bad_separator();
|
procedure xsd_TryStrToDate_date_bad_separator();
|
||||||
procedure xsd_TryStrToDate_date_time_bad_separator();
|
procedure xsd_TryStrToDate_date_time_bad_separator();
|
||||||
procedure xsd_TryStrToDate_date_time_timezone_z();
|
procedure xsd_TryStrToDate_date_time_timezone_z();
|
||||||
@@ -568,6 +569,38 @@ begin
|
|||||||
do_check('1976-10-12T23:34:56.078', 1976,10,12, 23,34,56,78);
|
do_check('1976-10-12T23:34:56.078', 1976,10,12, 23,34,56,78);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTest_DateUtils.xsd_TryStrToDate_date_time_fractional_second_2();
|
||||||
|
|
||||||
|
procedure do_check(
|
||||||
|
const AString : string;
|
||||||
|
const AY, AM, ADY : Word;
|
||||||
|
const AHH, AMN, ASS, ASSSS : Word
|
||||||
|
);
|
||||||
|
var
|
||||||
|
d : TDateTimeRec;
|
||||||
|
y,m,dy : Word;
|
||||||
|
hh,mn,ss, ssss : Word;
|
||||||
|
begin
|
||||||
|
d := xsd_StrToDate(AString,xdkDateTime);
|
||||||
|
DecodeDate(d.Date,y,m,dy);
|
||||||
|
CheckEquals(AY,y,'Year');
|
||||||
|
CheckEquals(AM,m,'Month');
|
||||||
|
CheckEquals(ADY,dy,'Day');
|
||||||
|
DecodeTime(d.Date,hh,mn,ss,ssss);
|
||||||
|
CheckEquals(AHH,hh,'Hour');
|
||||||
|
CheckEquals(AMN,mn,'Minute');
|
||||||
|
CheckEquals(ASS,ss,'Second');
|
||||||
|
CheckEquals(ASSSS,ssss,'MiliSecond');
|
||||||
|
CheckEquals(0,d.HourOffset,'HourOffset');
|
||||||
|
CheckEquals(0,d.MinuteOffset,'MinuteOffset');
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
//'-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
|
||||||
|
do_check('1976-10-12T23:34:56.123456789', 1976,10,12, 23,34,56,123);
|
||||||
|
do_check('2010-01-04T23:43:21.569358Z', 2010,01,04, 23,43,21,569);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTest_DateUtils.xsd_TryStrToDate_date_time_timezone_1();
|
procedure TTest_DateUtils.xsd_TryStrToDate_date_time_timezone_1();
|
||||||
var
|
var
|
||||||
s : string;
|
s : string;
|
||||||
|
Reference in New Issue
Block a user