diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index cdab7970ef..ad085b3974 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -234,6 +234,10 @@ QtCore now return an empty QString, QStringRef or QByteArray respectively. in Qt 4 they returned a null QString or a null QStringRef. +* QDate, QTime, and QDateTime have undergone important behavioural changes: + * QDate::setYMD() is deprecated, use QDate::setDate() instead + + QtGui ----- * Accessibility has been refactored. The hierachy of accessible objects is implemented via diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 530b9e6b3f..6430e2c8bc 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -832,7 +832,9 @@ QString QDate::toString(const QString& format) const #endif //QT_NO_DATESTRING /*! - \obsolete + \fn bool setYMD(int y, int m, int d) + + \deprecated in 5.0, use setDate() instead. Sets the date's year \a y, month \a m, and day \a d. @@ -842,13 +844,6 @@ QString QDate::toString(const QString& format) const Use setDate() instead. */ -bool QDate::setYMD(int y, int m, int d) -{ - if (uint(y) <= 99) - y += 1900; - return setDate(y, m, d); -} - /*! \since 4.2 diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h index 1a0526a64b..056b0debf1 100644 --- a/src/corelib/tools/qdatetime.h +++ b/src/corelib/tools/qdatetime.h @@ -84,7 +84,11 @@ public: QString toString(Qt::DateFormat f = Qt::TextDate) const; QString toString(const QString &format) const; #endif - bool setYMD(int y, int m, int d); +#if QT_DEPRECATED_SINCE(5,0) +QT_DEPRECATED inline bool setYMD(int y, int m, int d) +{ if (uint(y) <= 99) y += 1900; return setDate(y, m, d); } +#endif + bool setDate(int year, int month, int day); void getDate(int *year, int *month, int *day); diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index b88d66696f..1c2cb6f0f0 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -1134,7 +1134,7 @@ const QDBusArgument &operator>>(const QDBusArgument &a, QDate &date) a.endStructure(); if (y != 0 && m != 0 && d != 0) - date.setYMD(y, m, d); + date.setDate(y, m, d); else date = QDate(); return a; diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index de3b07750a..c7ad810084 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -472,7 +472,7 @@ static void _q_fixupDateTime(QDateTime *dateTime) const int futureTolerance = 86400; if (dateTime->secsTo(QDateTime::currentDateTime()) < -futureTolerance) { QDate d = dateTime->date(); - d.setYMD(d.year() - 1, d.month(), d.day()); + d.setDate(d.year() - 1, d.month(), d.day()); dateTime->setDate(d); } } diff --git a/tests/auto/corelib/tools/qdate/tst_qdate.cpp b/tests/auto/corelib/tools/qdate/tst_qdate.cpp index 1a1c344f07..1827b4c76f 100644 --- a/tests/auto/corelib/tools/qdate/tst_qdate.cpp +++ b/tests/auto/corelib/tools/qdate/tst_qdate.cpp @@ -703,6 +703,7 @@ void tst_QDate::yearsZeroToNinetyNine() QVERIFY(QDate::isValid(1, 2, 3)); QVERIFY(QDate::isValid(-1, 2, 3)); +#if QT_DEPRECATED_SINCE(5,0) { QDate dt; dt.setYMD(1, 2, 3); @@ -710,6 +711,7 @@ void tst_QDate::yearsZeroToNinetyNine() QCOMPARE(dt.month(), 2); QCOMPARE(dt.day(), 3); } +#endif { QDate dt;