diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-13 05:05:43 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-13 05:05:43 (GMT) |
commit | 8c6b5c53a2f6f8c9113fa616b458dde0be86a9e2 (patch) | |
tree | f3883fb4fce6227a9fe33a4d53449ffc4c4cf505 /src/corelib/tools/qdatetime.cpp | |
parent | 50711dd7aa22052eff58431d9f4e95e1a688047e (diff) | |
parent | d41ccae68683dd0d35c20affec7e5c55ce6bca37 (diff) | |
download | Qt-8c6b5c53a2f6f8c9113fa616b458dde0be86a9e2.zip Qt-8c6b5c53a2f6f8c9113fa616b458dde0be86a9e2.tar.gz Qt-8c6b5c53a2f6f8c9113fa616b458dde0be86a9e2.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (159 commits)
Doc: Adding loading image to search textbox
qdoc: Yet another revision of the top doc page.
Doc: Update on web template
Added QDateTime::msecsTo()
Doc: Fixed tables and images for the new docs
qdoc: Yet another revision of the top doc page.
Revert "Improve QUrl handling of local file paths"
Revert "[QNAM FTP] Check for the "ftp" scheme case-insensitively"
Revert "QUrl::fromLocalFile: fix silly mistake: it's fromNativeSeparators, not to"
Revert "Use QUrl::isLocalFile and fix the scheme checking in local URLs."
qdoc: Another revision of the top doc page.
Doc correction to css
Doc: Updates to the html template and javascript
tst_SuiteTest: Fix a meaningless switch statement
My 4.7.0 changelog entries.
qdoc: Fixed annotated list generation to use <td>, not <th>.
Doc: Tuning search script
qdoc: Reorganized examples panel.
Doc: Chages to search feature, css and table order
QtDeclarative: avoid waiting for a network load on URIs with empty schemes.
...
Diffstat (limited to 'src/corelib/tools/qdatetime.cpp')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 9afcd80..9f5d8c6 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1705,7 +1705,7 @@ int QTime::secsTo(const QTime &t) const Note that the time will wrap if it passes midnight. See addSecs() for an example. - \sa addSecs(), msecsTo() + \sa addSecs(), msecsTo(), QDateTime::addMSecs() */ QTime QTime::addMSecs(int ms) const @@ -1734,7 +1734,7 @@ QTime QTime::addMSecs(int ms) const seconds in a day, the result is always between -86400000 and 86400000 ms. - \sa secsTo(), addMSecs() + \sa secsTo(), addMSecs(), QDateTime::msecsTo() */ int QTime::msecsTo(const QTime &t) const @@ -2042,10 +2042,11 @@ int QTime::elapsed() const later. You can increment (or decrement) a datetime by a given number of - seconds using addSecs(), or days using addDays(). Similarly you can - use addMonths() and addYears(). The daysTo() function returns the - number of days between two datetimes, and secsTo() returns the - number of seconds between two datetimes. + milliseconds using addMSecs(), seconds using addSecs(), or days + using addDays(). Similarly you can use addMonths() and addYears(). + The daysTo() function returns the number of days between two datetimes, + secsTo() returns the number of seconds between two datetimes, and + msecsTo() returns the number of milliseconds between two datetimes. QDateTime can store datetimes as \l{Qt::LocalTime}{local time} or as \l{Qt::UTC}{UTC}. QDateTime::currentDateTime() returns a @@ -2719,7 +2720,7 @@ QDateTime QDateTime::addSecs(int s) const later than the datetime of this object (or earlier if \a msecs is negative). - \sa addSecs(), secsTo(), addDays(), addMonths(), addYears() + \sa addSecs(), msecsTo(), addDays(), addMonths(), addYears() */ QDateTime QDateTime::addMSecs(qint64 msecs) const { @@ -2731,7 +2732,7 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const datetime. If the \a other datetime is earlier than this datetime, the value returned is negative. - \sa addDays(), secsTo() + \sa addDays(), secsTo(), msecsTo() */ int QDateTime::daysTo(const QDateTime &other) const @@ -2766,6 +2767,33 @@ int QDateTime::secsTo(const QDateTime &other) const } /*! + Returns the number of milliseconds from this datetime to the \a other + datetime. If the \a other datetime is earlier than this datetime, + the value returned is negative. + + Before performing the comparison, the two datetimes are converted + to Qt::UTC to ensure that the result is correct if one of the two + datetimes has daylight saving time (DST) and the other doesn't. + + \sa addMSecs(), daysTo(), QTime::msecsTo() +*/ + +qint64 QDateTime::msecsTo(const QDateTime &other) const +{ + QDate selfDate; + QDate otherDate; + QTime selfTime; + QTime otherTime; + + d->getUTC(selfDate, selfTime); + other.d->getUTC(otherDate, otherTime); + + return (static_cast<qint64>(selfDate.daysTo(otherDate)) * static_cast<qint64>(MSECS_PER_DAY)) + + static_cast<qint64>(selfTime.msecsTo(otherTime)); +} + + +/*! \fn QDateTime QDateTime::toTimeSpec(Qt::TimeSpec specification) const Returns a copy of this datetime configured to use the given time |