QDateTime dateTime = QDateTime::fromString("1.30.1", "M.d.s");
// dateTime is January 30 in 1900 at 00:00:01.
//! [14]
+
+//! [15]
+QDateTime startDate(QDate(2012, 7, 6), QTime(8, 30, 0));
+QDateTime endDate(QDate(2012, 7, 7), QTime(16, 30, 0));
+qDebug() << "Days from startDate to endDate: " << startDate.daysTo(endDate);
+
+startDate = QDateTime(QDate(2012, 7, 6), QTime(23, 55, 0));
+endDate = QDateTime(QDate(2012, 7, 7), QTime(0, 5, 0));
+qDebug() << "Days from startDate to endDate: " << startDate.daysTo(endDate);
+
+qSwap(startDate, endDate); // Make endDate before startDate.
+qDebug() << "Days from startDate to endDate: " << startDate.daysTo(endDate);
+//! [15]
\ No newline at end of file
/*!
Returns the number of days from this datetime to the \a other
- datetime. If the \a other datetime is earlier than this datetime,
+ datetime. The number of days is counted as the number of times
+ midnight is reached between this datetime to the \a other
+ datetime. This means that a 10 minute difference from 23:55 to
+ 0:05 the next day counts as one day.
+
+ If the \a other datetime is earlier than this datetime,
the value returned is negative.
+ Example:
+ \snippet code/src_corelib_tools_qdatetime.cpp 15
+
\sa addDays(), secsTo(), msecsTo()
*/