views:

155

answers:

2

In Windows Mobile I am using FindFirstFile/FindNextFile to search for some files. As part of the results I am getting a WIN32_FIND_DATA structure which contains one search result. This structure contains 3 FILETIME structures for file creation, last write and last access times.

Then I am converting these structures to SYSTEMTIME using FileTimeToSystemTime function. My problem starts here. In the SYSTEMTIME structure hour field does not match the real hour field from the time. I figure out WM is making an adjustment based on time zone and daylight savings time.

For example if time is created on 5:44:30 and I am on GMT +1, SYSTEMTIME structure reports 4:44:30.

I would like to know if anybody has any ideas how to get real time values before this adjustment?

+1  A: 

The FileTime you are getting is in UTC, use FileTimeToLocalFileTime before you convert it to SYSTEMTIME.

EDIT: Fixed link.

Simon Jensen
Thanks, solved my problem. Link to the WM related function maybe better though (http://msdn.microsoft.com/en-us/library/aa908762.aspx)
Szere Dyeri
Oh, yeah, definitely, hadn't noticed I'd ventured into the wrong category. Updating my answer to avoid any future confusion.
Simon Jensen
+1  A: 

I'm not clear what you think the exact problem is. The FindFirst/Next is returning file information of the file, so that time is correct - it is what is stored with the file. Are you saying that you're expecting it to be in UTC/zulu time (which is not the same a s a SYSTEMTIME struct), rather than in an offset format like local time? Or the reverse? Regardless, the file system obviously disagrees with that assumption and is storing the times oposite what you think it should. If you want to adjust the time associated with the file, you'll have to do a manual calculation with the info returned from GetTimezoneInformation or with a call to FileTimeToLocalFileTime. You might want to look over all of the CE time functions.

ctacke