[Qt-interest] Behavior of QDateTime.secsTo() Differs from QT'sDocumentation

Tony Rietwyk tony.rietwyk at rightsoft.com.au
Fri Jun 4 08:32:44 CEST 2010


Alex, 
 
According to the Windows Calculator applet, 110 years * 365 days * 24 hours * 3600 seconds per hour gives roughly 3.5 billion seconds which obviously overflows a signed 32 bit int.  
 
I suppose the docs could have a warning that the function is only good for dates up to 63 years apart.... 
 
Tony.
 

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Alex
Sent: Friday, 4 June 2010 13:48
To: qt-interest
Subject: [Qt-interest] Behavior of QDateTime.secsTo() Differs from QT'sDocumentation


Hi,

Why the behavior of QDateTime.secsTo() differs from QT's documentation.

My code:

QDateTime last(QDate(1900, 1, 1));
QDateTime now = QDateTime::currentDateTime();
qDebug() << last.secsTo(now);


QT's documentation says:


int QDateTime::secsTo ( const QDateTime & other ) const


Returns the number of seconds from this datetime to the other datetime. If the other datetime is earlier than this datetime, the value returned is negative.



But after I run my code, it outputs a negative number (-810326525).
Can anybody tell me why?
Thanks!

Alex 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100604/fba0e1df/attachment.html 


More information about the Qt-interest-old mailing list