The code snippet below shows an issue with how the milliseconds in a TDateTime variable are interpreted:
The following should be identical:
01:02:03.1
01:02:03.10
01:02:03.100
But the first will be converted to ".001" and the second to ".010"
Likewise, ".02" and ".020" should be treated the same, but are not. Leading zeros are ignored, up to a total of 4 digits provided.
{ This program demonstrates a problem with how milliseconds are converted from STRING to DATETIME }
Uses sysutils;
Procedure TestStr (S : String);
begin
Writeln (S:25, ' .... ', FormatDateTime('mm/dd/yyyy hh:nn:ss.zz', StrToDateTime(S)));
end;
Begin
TestStr(DateTimeToStr(Now));
writeln;
TestStr('5/5/1999 15:50:10.1');
TestStr('5/5/1999 15:50:10.10');
TestStr('5/5/1999 15:50:10.100');
writeln;
TestStr('1/1/2019 15:50:10.2');
TestStr('1/1/2019 15:50:10.02');
TestStr('1/1/2019 15:50:10.020');
TestStr('1/1/2019 15:50:10.0200');
End.
Is anyone seeing the same thing?
This is with FPC/Lazarus Fixes branch (see sig for current build)