[Qt-interest] Behavior of QDateTime.secsTo() Differs from QT'sDocumentation
Alex
shao.tu at gmail.com
Fri Jun 4 08:39:34 CEST 2010
Thanks Tony.
You remind me of the overflow issue :-(
2010/6/4 Tony Rietwyk <tony.rietwyk at rightsoft.com.au>
> 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
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100604/59d3ebbf/attachment.html
More information about the Qt-interest-old
mailing list