Jump to content

How to convert timestamp(64 bit) to TDateTime?


elGringo

Recommended Posts

Hi, everyone! 

 

I use Indy, and after idFTP.put I want to get info about File Creation DateTime on Server

 

I do like following...

...     
List;

                        Memo1.Lines.Clear;


                         for i := 0 to IdFTP.ListResult.Count-1 do
                         begin
                         Memo1.Lines.Add(IdFTP.ListResult[i]);
                         end;
... 

 As a result i get info like this

size=0;type=cdir;create=20160911195120;modify=20160912135842;windows.lastaccesstime=20160912135842;win32.ea=0x00002010; .
size=0;type=pdir;create=20160911195120;modify=20160912135842;windows.lastaccesstime=20160912135842;win32.ea=0x00002010; ..
size=0;type=dir;create=20160912102900;modify=20160912102900;windows.lastaccesstime=20160912102900;win32.ea=0x00002010; 2016
size=2360;type=file;create=20160912135842;modify=20160912135842;windows.lastaccesstime=20160912135842;win32.ea=0x00002020; cancel(1).png

As I understand this is create=20160911195120; is timestamp in 64 bit

 

Ok, with Regular Expressions I can get only this numbers (20160911195120) but how to convert them to the readable DateTime???

 

I tried FileDateToDateTime function, but 20160911195120 is not an integer? 

 

I meet this situation first time. Who can help?

 

Regards, 

 

Link to comment
Share on other sites

Ok, i tried

   FFileTime.dwLowDateTime:=20160911195120;
                                FFileTime.dwHighDateTime:=20160911195120;

                             for i := 0 to Memo1.Lines.Count-1 do
                               begin

                               FileTimeToLocalFileTime( FFileTime, LTime);
                               FileTimeToSystemTime( LTime, SystemTime );

                               Memo2.Lines.Add(//'value='+

                                DateTimeToStr(
                                SystemTimeToDateTime( SystemTime)
                                              )


                              );


                               end;

as a result

 

11.06.6156 4:33:57  :blink:

 

Don't understand how it works for the moment <_<

Link to comment
Share on other sites

Ok, my decision is following - Zilav, big thanks to you for help!!!

procedure TVisualFrame_PSFTPClient.bTestClick(Sender: TObject);
var
    FFileTimeLocalized:TFileTime;
    FFileTime:TFileTime;
    FLocalFileTime:TFileTime;


    SystemTimeLocalized:TSystemtime;

    SystemTime:TSystemtime;


    datetime: TDateTime;
    IndyString:String;

begin

IndyString:='20160912210450'; // <<Example

datetime := EncodeDateTime(StrToInt(Copy(IndyString, 1, 4)),
                            StrToInt(Copy(IndyString, 5, 2)),
                            StrToInt(Copy(IndyString, 7, 2)),
                            StrToInt(Copy(IndyString, 9, 2)),
                            StrToInt(Copy(IndyString, 11, 2)),
                            StrToInt(Copy(IndyString, 13, 2)), 0);


DateTimeToSystemTime(datetime,SystemTime);
SystemTimeToFileTime(SystemTime,FFileTime);
FileTimeToLocalFileTime(FFileTime,FFileTimeLocalized);

FileTimeToSystemTime(FFileTimeLocalized,SystemTimeLocalized);

ShowMessage( 'GMT Localized '+
DateTimeToStr(
SystemTimeToDateTime( SystemTimeLocalized))

);


ShowMessage( 'GMT 0 (Not Localized) '+
DateTimeToStr(datetime)
);



end;
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...