Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Android ADB-FS plugin development, filetime issue - TC BUG?

 
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) Printable version
View previous topic :: View next topic  
Author Message
Aleq
Junior Member
Junior Member


Joined: 07 Jun 2006
Posts: 34
Location: CZ, EU

PostPosted: Wed Apr 25, 2012 2:31 pm    Post subject: Android ADB-FS plugin development, filetime issue - TC BUG? Reply with quote

Hi Everybody.
I'm fixing and enhancing Sztupy's ADB-FS plugin accessing android device using ADB protocol. I'm tearing my hair off now because I can't get the time and date correctly. I have tried so many ways of converting FILETIME, unix timestamp, SYSTEMTIME, ...

I have narrowed the issue down to this:
Code:
UnixTimeToFileTime(fd->modificationTime, (LPFILETIME) FieldValue);


which is implemented:
Code:
 void UnixTimeToFileTime(time_t t, LPFILETIME pft) {
   long long ll;
   ll = Int32x32To64(t, 10000000) + 116444736000000000;
   pft->dwLowDateTime = (DWORD) ll;
   pft->dwHighDateTime = ll >> 32;
}


I even tried to get the time from http://www.epochconverter.com/ and inject it into the variable while debugging to see the result. It was off by several minutes and few hours again. Or I tried to construct the SYSTEMTIME and then used Microsoft's methods to convert that to FILETIME. Again, the same difference - few hours and some minutes off.

I would understand the hours (timezone) but minutes?

I'm desperate, so any information is welcome. Tested with latest TC7.57a and 8.0. VS C++ 2010 Express.

Thanks,
A.


Last edited by Aleq on Thu Apr 26, 2012 2:34 am; edited 1 time in total
Back to top
View user's profile Send private message
Aleq
Junior Member
Junior Member


Joined: 07 Jun 2006
Posts: 34
Location: CZ, EU

PostPosted: Thu Apr 26, 2012 2:09 am    Post subject: Reply with quote

Debugging...
http://img.ctrlv.in/4f98ff4797b6e.jpg
http://img.ctrlv.in/4f98ff32f2e9a.jpg

I'm currently in GMT+3 timezone, so this would explain those hours and I would be ok with that. I would convert the time. But what about those minutes:?: Am I missing something?
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Thu Apr 26, 2012 7:10 am    Post subject: Reply with quote

I have written an ADB plugin myself (private use, not really ready for release), and I'm also experiencing problems with time zones. At least the seconds are correct. I'm using the following code:

Code:
BOOL UnixTimeToLocalTime(long* mtime,LPFILETIME ft)
{
   if (*mtime==0)
      return false;
    struct tm* fttm=localtime(mtime);  // apparently Android returns local time
   if (fttm==NULL)
      return false;
    SYSTEMTIME st;

    st.wYear=fttm->tm_year;
    if (st.wYear<200)
        st.wYear+=1900;
    st.wMonth=fttm->tm_mon+1;  // 0-11 in struct tm*
    st.wDay=fttm->tm_mday;
    st.wHour=fttm->tm_hour;
    st.wMinute=fttm->tm_min;
    st.wSecond=fttm->tm_sec;
    st.wDayOfWeek=0;
    st.wMilliseconds=0;
    return SystemTimeToFileTime(&st,ft);
}


I tried with localtime(mtime) and gmtime(mtime), but got mixed results - some file times are off by 1 hour, some by two. In the end, I didn't release my ADB plugin because of this timestamp problem.
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Aleq
Junior Member
Junior Member


Joined: 07 Jun 2006
Posts: 34
Location: CZ, EU

PostPosted: Thu Apr 26, 2012 10:30 am    Post subject: Reply with quote

Hello Christian,
thank you for your answer. I tried your function but the minutes were off again. I have narrowed down how to simulate it now as even if I enter fixed/manual value, I don't get it correctly in the TC.

This is what I have in int __stdcall FsContentGetValueT(BOOL unicode,WCHAR* FileName,int FieldIndex,int UnitIndex,void* FieldValue,int maxlen,int flags):
Code:
long mtime = (long) fd->modificationTime;
GhislersUnixTimeToLocalTime(&mtime, (LPFILETIME) FieldValue);


the function narrowed down to:
Code:

BOOL GhislersUnixTimeToLocalTime(long* mtime,LPFILETIME ft)
{
   SYSTEMTIME st;

   st.wYear=2012;
   st.wMonth=5;
   st.wDay=10;
   st.wHour=13;
   st.wMinute=30;
   st.wSecond=0;
   st.wDayOfWeek=0;
   st.wMilliseconds=0;
   return SystemTimeToFileTime(&st,ft);
}


but I get:
Image: http://img.ctrlv.in/4f997775e39f2.jpg
i.e. 10.05.2012 16:22

I still see this is a fault in TC or...? I'm confused.

Thanks!
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 24602
Location: Switzerland

PostPosted: Fri Apr 27, 2012 2:16 am    Post subject: Reply with quote

What are you comparing the minutes to? I compared them with the minutes shown by Total Commander for Android, and they were the same.

Btw, you are using some strange custom columns view, what fields are you using? Can you try "Full" view instead?
_________________
Author of Total Commander
http://www.ghisler.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group