From c3590c76775c889fde13dc155c2a31508db612e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 14 Jan 2015 15:34:45 -0800 Subject: Update doc saying QDateTime::setTime with invalid time sets to midnight QDateTimePrivate::setDateTime has a comment saying this is intentional, so document it. Task-number: QTBUG-43704 Change-Id: Ic5d393bfd36e48a193fcffff13b965409eaf7be9 Reviewed-by: Martin Smith --- src/corelib/tools/qdatetime.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d52dea8d4f..082b721e82 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3296,8 +3296,8 @@ bool QDateTime::isDaylightTime() const } /*! - Sets the date part of this datetime to \a date. - If no time is set, it is set to midnight. + Sets the date part of this datetime to \a date. If no time is set yet, it + is set to midnight. If \a date is invalid, this QDateTime becomes invalid. \sa date(), setTime(), setTimeSpec() */ @@ -3309,7 +3309,14 @@ void QDateTime::setDate(const QDate &date) } /*! - Sets the time part of this datetime to \a time. + Sets the time part of this datetime to \a time. If \a time is not valid, + this function sets it to midnight. Therefore, it's possible to clear any + set time in a QDateTime by setting it to a default QTime: + + \code + QDateTime dt = QDateTime::currentDateTime(); + dt.setTime(QTime()); + \endcode \sa time(), setDate(), setTimeSpec() */ -- cgit v1.2.3