TSearchRec.TimeStamp is not accurate on Windows
Original Reporter info from Mantis: kluug.net @onpok
-
Reporter name: Ondrej Pokorny
Original Reporter info from Mantis: kluug.net @onpok
- Reporter name: Ondrej Pokorny
Description:
TSearchRec.TimeStamp loses precision because it is calculated from the converted DOS file time and not the original Windows file time.
Steps to reproduce:
program Project1;
uses Windows, SysUtils;
var
xSR: TRawByteSearchRec;
st, lt: TSystemTime;
begin
if FindFirst('*', faAnyFile, xSR) = 0 then
begin
try
repeat
if not((xSR.Name='..') or (xSR.Name='.') or (xSR.Name='')) then
begin
Writeln(xSR.Name);
Writeln(DateTimeToStr(FileDateToDateTime(xSR.Time)), ' - xSR.Time (inaccurate because of Longint precision)');
Writeln(DateTimeToStr(xSR.TimeStamp), ' - xSR.TimeStamp (should be accurate - bug!): ');
FileTimeToSystemTime(xSR.FindData.ftLastWriteTime, st);
if SystemTimeToTzSpecificLocalTime(nil, st, lt) then
Writeln(DateTimeToStr(SystemTimeToDateTime(lt)), ' - xSR.FindData.ftLastWriteTime (accurate)');
Writeln;
end;
until FindNext(xSR) <> 0;
finally
FindClose(xSR);
end;
end;
ReadLn;
end.
Additional information:
Patch attached.
Mantis conversion info:
- Mantis ID: 35906
- OS: Windows
- OS Build: Windows 10
- Platform: win32
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 42559 (#3d585db4)