elGringo Posted September 12, 2016 Posted September 12, 2016 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, Quote
elGringo Posted September 12, 2016 Author Posted September 12, 2016 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 Don't understand how it works for the moment Quote
zilav Posted September 12, 2016 Posted September 12, 2016 s := '20160911195120'; datetime := EncodeDateTime(StrToInt(Copy(s, 1, 4)), StrToInt(Copy(s, 5, 2)), StrToInt(Copy(s, 7, 2)), StrToInt(Copy(s, 9, 2)), StrToInt(Copy(s, 11, 2)), StrToInt(Copy(s, 13, 2)), 0); Quote
elGringo Posted September 12, 2016 Author Posted September 12, 2016 Yes)) Thank you, Zilav! I also decided like this, but it is datetime in GMT 0, now i am thinking how to cast it to locale time, for example difference with my windows watches is +5 hours. I almost found decision, will post it here little bit later... Quote
elGringo Posted September 12, 2016 Author Posted September 12, 2016 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; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.