[DUG] Help in getting file age

Jianming Lin (FMI) jianmingl at fmi.co.nz
Fri May 1 09:54:23 NZST 2009


Hi, Vik,

 

In NTFS, file time is recorded as UTC (before is called Greenwich Mean
Time).

 

Assume Now is 9:00am 01/05/09 in Auckland - GMT 9:00pm 30/04/09.

 

in New Delhi it is : 2:30am 01/05/09   -   (GMT : 9:00pm 30/04/09)  you
modify a file. 

10 min later, in New York USA, someone else 

At 5:10pm 30/04/09 ( GMT : 9:10pm 30/04/09) modify the file.

 

You can easily find which is newer by comparing the GMT time.

 

 

 

// FindData.ftLastWriteTime   is stored as UTC time format in hardisk

//---------------------------------------------------------------------

function GetFileUTC_Time(const FileName: string; var FileUTC_Time:
TSystemTime): boolean;

var Handle: THandle;

    FindData: TWin32FindData;

begin

  Handle := FindFirstFile(PChar(FileName), FindData);

  if Handle <> INVALID_HANDLE_VALUE then

  begin

    Windows.FindClose(Handle);

    if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then

      FileTimeToSystemTime(FindData.ftLastWriteTime, FileUTC_Time);

  end;

  Result := -1;

end;

 

 

________________________________

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Vikas...
Sent: Friday, 1 May 2009 2:07 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Help in getting file age

 

Dear Everyone,

I need a help in calculating the age of file.

I have checked the function file age. But it dint serve the purpose.

Reason being is. Let say i am sitting in India changed a file on 30th
April at 7:15pm. But on the other hand some one from america modifies
the same files at 9:30am on 30th April since we have time difference of
12 hours from US. So how do i make sure this file modified at 9:30am is
the new one.

Since according the file age filed modified at 7:15pm that is later one
is new. Which is not right.

Anyone ever worked on such things before.

I hope my query makes sense.

Cheers
Vik


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20090501/eecd0151/attachment-0001.html 


More information about the Delphi mailing list