TFindFile v4.12 and invalid argument to date encode

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TFindFile v4.12 and invalid argument to date encode

Postby tls_43017 » April 2nd, 2013, 8:13 pm

Kambiz,

I found a problem with TFindFile and thought you would like to know.

We received files from Canada where the file date is dd/mm/yyyy. We are in the USA the file date is mm/dd/yyyy.

We copied the files to ours servers and some of the file date got messed up. I had to put a try and except in the FileTimeToDateTime to process the files.

The error I am getting without the patch is “invalid argument to date encode”.

Is there a better way to address the error?

function FileTimeToDateTime(const FileTime: TFileTime): TDateTime;
var
LocalFileTime: TFileTime;
SystemTime: TSystemTime;
begin
try // added
FileTimeToLocalFileTime(FileTime, LocalFileTime);
FileTimeToSystemTime(LocalFileTime, SystemTime);
Result := SystemTimeToDateTime(SystemTime);
except // added
Result := StrToDateTime('01/01/1980 12:00:00'); // added
end; // added
end;
tls_43017
Member
Member
 
Posts: 3
Joined: April 2nd, 2013, 7:59 pm

Re: TFindFile v4.12 and invalid argument to date encode

Postby Kambiz » April 3rd, 2013, 5:26 pm

None of the date/time related functions that are used in FindFile are culture sensitive. It sounds to me like some other kind of problem.
Could you please send me a sample file to check it out? And, what version of Delphi do you use?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: TFindFile v4.12 and invalid argument to date encode

Postby tls_43017 » April 4th, 2013, 12:50 am

Kambiz,

I have attached a zip with the invalid dates. You may have to unzip them on a Linux or Windows server. I unzipped them on my Windows 8 PC and it reset the dates to 1/1/1980.

?) 12:40 AM 732 PERMIT.EXP
?) 12:40 AM 1,218 INTERMDO.WS
?) 12:40 AM 2,118 TRANS.ANA
?) 12:40 AM 3,987 MINISTER.WPM
Attachments
INTER.zip
(32.64 KiB) Downloaded 80 times
tls_43017
Member
Member
 
Posts: 3
Joined: April 2nd, 2013, 7:59 pm

Re: TFindFile v4.12 and invalid argument to date encode

Postby Kambiz » April 15th, 2013, 4:21 pm

Sorry for the delay in writing back.

With FindFile in Delphi 7 everything was fine.
But the timestamp of your files are really odd. I suppose they are belong to the era that OS's had nothing to do with time zones and 4-digit year. :)
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Re: TFindFile v4.12 and invalid argument to date encode

Postby tls_43017 » April 17th, 2013, 11:33 pm

Adding the try..except catches the bad date/time and allows the processing to continue.
tls_43017
Member
Member
 
Posts: 3
Joined: April 2nd, 2013, 7:59 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 35 guests

cron