PDA

View Full Version : QDateTime and comparsion



Talei
17th May 2010, 16:19
Hello,
I want compare two DataTime but result is strange to me, and I don't know why is that happening. My code is:


QDateTime srcLastmodif, dstLastmodif;
srcLastmodif.setTimeSpec( Qt::UTC );
dstLastmodif.setTimeSpec( Qt::UTC );

finfo.setFile( dstList[i] );
dstLastmodif = finfo.lastModified();

finfo.setFile( srcList[i] );
srcLastmodif = finfo.lastModified();

qDebug() << srcLastmodif << " > " << dstLastmodif << " : " << (srcLastmodif > dstLastmodif);
Files have identical lastModified time, but result to above qDebug is:


srcLastmodif > dstLastmodif : (srcLastmodif > dstLastmodif)
QDateTime("Pt 23. kwi 13:47:08 2010") > QDateTime("Pt 23. kwi 13:47:08 2010") : true
QDateTime("Pt 23. kwi 13:47:10 2010") > QDateTime("Pt 23. kwi 13:47:10 2010") : false
QDateTime("Pt 23. kwi 13:47:09 2010") > QDateTime("Pt 23. kwi 13:47:09 2010") : true
QDateTime("Pt 23. kwi 13:47:09 2010") > QDateTime("Pt 23. kwi 13:47:09 2010") : true
As You can see the above 5 qdatatime are identical (assuming that qDebug print all the data in obj. ).
So my question: Why only 1 of comparison is FALSE, shouldn't all be FALSE?

Thank you for any hints, because probably I miss something obvious here.