PDA

View Full Version : QFileInfo::lastModified seems to be one hour off



hardgeus
30th April 2007, 17:38
I have a QT program that has been functioning properly in Windows for a few months, but recently (after the DST shift maybe?) started acting strangely. I have the following function:


QDateTime frmMain::GetLocalStamp( QString sFilename, bool *pbSuccess ) {
QDateTime obStamp;

QFileInfo obFileInfo(sFilename);
if (!obFileInfo.exists() ) {
qDebug() << "File " << sFilename << " does not exist, no local stamp";
*pbSuccess = false;
return( obStamp );
}

//qDebug() << "Checking local stamp on " << sFilename;

obStamp = obFileInfo.lastModified();

*pbSuccess = true;
return( obStamp );
} //GetLocalStamp


If I qDebug() the returned QDateTime object, it is one hour off from the time the Operating system reports. Is this a known issue, or is there some step I am missing?

jacek
30th April 2007, 19:00
What does obStamp.timeSpec() return?

hardgeus
1st May 2007, 15:15
What does obStamp.timeSpec() return?

0 (Qt::LocalTime)

jacek
1st May 2007, 16:35
I couldn't find anything in Trolltech's task tracker, so I think it will be better if you prepare a minimal compilable example and contact the Trolls.

hardgeus
1st May 2007, 17:03
I couldn't find anything in Trolltech's task tracker, so I think it will be better if you prepare a minimal compilable example and contact the Trolls.

This is starting to look like a Windows issue more than a QT issue. I am setting the timestamp of the file myself using utime in another part of the code (this program downloads updates off of the Internet, sets their timestamp to the server timestamp, and upon subsequent executions, compares client-side stamps to server-side stamps).

http://img389.imageshack.us/img389/1616/datewronghi5.th.jpg (http://img389.imageshack.us/my.php?image=datewronghi5.jpg)

Check out this screen shot...I ran a little test app to show the modify time of two executables, and I am getting two different results, even though Windows is showing an identical modify time. What is even stranger is that neither result I get from the QT call is the same as what Windows reports, however, the 16:14 time is what I tried to set it to with utime (this file is a copy and paste of the file I downloaded.)

Is there something "under the hood" of the stamps that could be causing this? Do Windows files have any sort of meta-info that may be scrambling this?