Possible issue with ConvertFileTimeToDateTime giving results different from File Explorer due to Daylight Savings Time.
Issue #388
resolved
This results in TFileSystemEntry.LastWriteTime being different that the value displayed in FileExplorer if the FileTime was during DST. The Microsoft docs for FileTimeToLocalFileTime mention that it doesn’t support daylight savings information and gives the call sequence needed. Here’s my simple version which gives results that match FileExplorer:
function MyFileTimeToDateTime(AFileTime: FILETIME): TDateTime;
var
SysTime: TSystemTime;
LocTime: TSystemTime;
begin
Result := 0;
if FileTimeToSystemTime(AFileTime, SysTime) then
if SystemTimeToTzSpecificLocalTime(nil, SysTime, LocTime) then
Result := SystemTimeToDateTime(LocTime);
end;
Comments (3)
-
reporter -
repo owner - changed status to resolved
fixed issue
#388→ <<cset 9c7387fa8a06>>
-
repo owner fixed issue
#388→ <<cset 402177aa4f73>>
- Log in to comment
Also it might be convenient for TFileSystemEntry to give access to the raw FILETIME values (just a minor enhancement request.) In my testing the file/dir enumerators work excellently btw!