summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-01-23 18:01:24 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2020-05-05 15:34:15 +0200
commitca222646ff7890cf6e2d0363ab547947055284f6 (patch)
tree87db44dc988ab3e347d583f874a84071983ade81
parent9c85078dc2bc8e728e9c0c6c797d29491da5d2f7 (diff)
Purge from Q(Date|Time)+ most things marked to go at Qt 6
Change-Id: Ib3f48c74132b47649dc7b4cbacf2cefed5a57687 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/time/qdatetime.cpp447
-rw-r--r--src/corelib/time/qdatetime.h46
-rw-r--r--tests/auto/corelib/time/qdate/tst_qdate.cpp154
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp37
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm6
5 files changed, 4 insertions, 686 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index eb4beff9e6..34725a735d 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -356,20 +356,6 @@ static int fromOffsetString(QStringView offsetString, bool *valid) noexcept
*****************************************************************************/
/*!
- \since 4.5
-
- \enum QDate::MonthNameType
-
- This enum describes the types of the string representation used
- for the month name.
-
- \value DateFormat This type of name can be used for date-to-string formatting.
- \value StandaloneFormat This type is used when you need to enumerate months or weekdays.
- Usually standalone names are represented in singular forms with
- capitalized first letter.
-*/
-
-/*!
\class QDate
\inmodule QtCore
\reentrant
@@ -1028,175 +1014,6 @@ QDateTime QDate::endOfDay(const QTimeZone &zone) const
}
#endif // timezone
-#if QT_DEPRECATED_SINCE(5, 11) && QT_CONFIG(textdate)
-
-/*!
- \since 4.5
- \deprecated
-
- Returns the short name of the \a month for the representation specified
- by \a type.
-
- The months are enumerated using the following convention:
-
- \list
- \li 1 = "Jan"
- \li 2 = "Feb"
- \li 3 = "Mar"
- \li 4 = "Apr"
- \li 5 = "May"
- \li 6 = "Jun"
- \li 7 = "Jul"
- \li 8 = "Aug"
- \li 9 = "Sep"
- \li 10 = "Oct"
- \li 11 = "Nov"
- \li 12 = "Dec"
- \endlist
-
- The month names will be localized according to the system's
- locale settings, i.e. using QLocale::system().
-
- Returns an empty string if the date is invalid.
-
- \sa toString(), longMonthName(), shortDayName(), longDayName()
-*/
-
-QString QDate::shortMonthName(int month, QDate::MonthNameType type)
-{
- switch (type) {
- case QDate::DateFormat:
- return QCalendar().monthName(QLocale::system(), month,
- QCalendar::Unspecified, QLocale::ShortFormat);
- case QDate::StandaloneFormat:
- return QCalendar().standaloneMonthName(QLocale::system(), month,
- QCalendar::Unspecified, QLocale::ShortFormat);
- }
- return QString();
-}
-
-/*!
- \since 4.5
- \deprecated
-
- Returns the long name of the \a month for the representation specified
- by \a type.
-
- The months are enumerated using the following convention:
-
- \list
- \li 1 = "January"
- \li 2 = "February"
- \li 3 = "March"
- \li 4 = "April"
- \li 5 = "May"
- \li 6 = "June"
- \li 7 = "July"
- \li 8 = "August"
- \li 9 = "September"
- \li 10 = "October"
- \li 11 = "November"
- \li 12 = "December"
- \endlist
-
- The month names will be localized according to the system's
- locale settings, i.e. using QLocale::system().
-
- Returns an empty string if the date is invalid.
-
- \sa toString(), shortMonthName(), shortDayName(), longDayName()
-*/
-
-QString QDate::longMonthName(int month, MonthNameType type)
-{
- switch (type) {
- case QDate::DateFormat:
- return QCalendar().monthName(QLocale::system(), month,
- QCalendar::Unspecified, QLocale::LongFormat);
- case QDate::StandaloneFormat:
- return QCalendar().standaloneMonthName(QLocale::system(), month,
- QCalendar::Unspecified, QLocale::LongFormat);
- }
- return QString();
-}
-
-/*!
- \since 4.5
- \deprecated
-
- Returns the short name of the \a weekday for the representation specified
- by \a type.
-
- The days are enumerated using the following convention:
-
- \list
- \li 1 = "Mon"
- \li 2 = "Tue"
- \li 3 = "Wed"
- \li 4 = "Thu"
- \li 5 = "Fri"
- \li 6 = "Sat"
- \li 7 = "Sun"
- \endlist
-
- The day names will be localized according to the system's
- locale settings, i.e. using QLocale::system().
-
- Returns an empty string if the date is invalid.
-
- \sa toString(), shortMonthName(), longMonthName(), longDayName()
-*/
-
-QString QDate::shortDayName(int weekday, MonthNameType type)
-{
- switch (type) {
- case QDate::DateFormat:
- return QLocale::system().dayName(weekday, QLocale::ShortFormat);
- case QDate::StandaloneFormat:
- return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat);
- }
- return QString();
-}
-
-/*!
- \since 4.5
- \deprecated
-
- Returns the long name of the \a weekday for the representation specified
- by \a type.
-
- The days are enumerated using the following convention:
-
- \list
- \li 1 = "Monday"
- \li 2 = "Tuesday"
- \li 3 = "Wednesday"
- \li 4 = "Thursday"
- \li 5 = "Friday"
- \li 6 = "Saturday"
- \li 7 = "Sunday"
- \endlist
-
- The day names will be localized according to the system's
- locale settings, i.e. using QLocale::system().
-
- Returns an empty string if the date is invalid.
-
- \sa toString(), shortDayName(), shortMonthName(), longMonthName()
-*/
-
-QString QDate::longDayName(int weekday, MonthNameType type)
-{
- switch (type) {
- case QDate::DateFormat:
- return QLocale::system().dayName(weekday, QLocale::LongFormat);
- case QDate::StandaloneFormat:
- return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat);
- }
- return QString();
-}
-#endif // textdate && deprecated
-
#if QT_CONFIG(datestring) // depends on, so implies, textdate
static QString toStringTextDate(QDate date)
@@ -1416,20 +1233,6 @@ QString QDate::toString(const QString &format, QCalendar cal) const
#endif // datestring
/*!
- \fn bool QDate::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.
-
- If \a y is in the range 0 to 99, it is interpreted as 1900 to
- 1999.
- Returns \c false if the date is invalid.
-
- Use setDate() instead.
-*/
-
-/*!
\since 4.2
Sets this to represent the date, in the Gregorian calendar, with the given
@@ -1492,17 +1295,6 @@ void QDate::getDate(int *year, int *month, int *day) const
*day = ok ? parts.day : 0;
}
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-/*!
- \overload
- \internal
-*/
-void QDate::getDate(int *year, int *month, int *day)
-{
- qAsConst(*this).getDate(year, month, day);
-}
-#endif // < Qt 6
-
/*!
Returns a QDate object containing a date \a ndays later than the
date of this object (or earlier if \a ndays is negative).
@@ -2699,77 +2491,6 @@ bool QTime::isValid(int h, int m, int s, int ms)
return (uint)h < 24 && (uint)m < 60 && (uint)s < 60 && (uint)ms < 1000;
}
-#if QT_DEPRECATED_SINCE(5, 14) // ### Qt 6: remove
-/*!
- Sets this time to the current time. This is practical for timing:
-
- \snippet code/src_corelib_tools_qdatetime.cpp 10
-
- \sa restart(), elapsed(), currentTime()
-*/
-
-void QTime::start()
-{
- *this = currentTime();
-}
-
-/*!
- Sets this time to the current time and returns the number of
- milliseconds that have elapsed since the last time start() or
- restart() was called.
-
- This function is guaranteed to be atomic and is thus very handy
- for repeated measurements. Call start() to start the first
- measurement, and restart() for each later measurement.
-
- Note that the counter wraps to zero 24 hours after the last call
- to start() or restart().
-
- \warning If the system's clock setting has been changed since the
- last time start() or restart() was called, the result is
- undefined. This can happen when daylight-saving time is turned on
- or off.
-
- \sa start(), elapsed(), currentTime()
-*/
-
-int QTime::restart()
-{
- QTime t = currentTime();
- int n = msecsTo(t);
- if (n < 0) // passed midnight
- n += 86400*1000;
- *this = t;
- return n;
-}
-
-/*!
- Returns the number of milliseconds that have elapsed since the
- last time start() or restart() was called.
-
- Note that the counter wraps to zero 24 hours after the last call
- to start() or restart.
-
- Note that the accuracy depends on the accuracy of the underlying
- operating system; not all systems provide 1-millisecond accuracy.
-
- \warning If the system's clock setting has been changed since the
- last time start() or restart() was called, the result is
- undefined. This can happen when daylight-saving time is turned on
- or off.
-
- \sa start(), restart()
-*/
-
-int QTime::elapsed() const
-{
- int n = msecsTo(currentTime());
- if (n < 0) // passed midnight
- n += 86400 * 1000;
- return n;
-}
-#endif // Use QElapsedTimer instead !
-
/*****************************************************************************
QDateTime static helper functions
*****************************************************************************/
@@ -3759,20 +3480,6 @@ QDateTime::QDateTime() noexcept(Data::CanBeSmall)
{
}
-
-#if QT_DEPRECATED_SINCE(5, 17) // ### Qt 6: remove
-/*!
- Constructs a datetime with the given \a date, using Qt::LocalTime as the
- timeSpec() and the time at the start of that date.
-
- \sa QDate::startOfDay()
-*/
-QDateTime::QDateTime(QDate date)
- : QDateTime(date.startOfDay(Qt::LocalTime, 0))
-{
-}
-#endif
-
/*!
Constructs a datetime with the given \a date and \a time, using
the time specification defined by \a spec and \a offsetSeconds seconds.
@@ -4249,38 +3956,6 @@ qint64 QDateTime::toSecsSinceEpoch() const
return toMSecsSinceEpoch() / 1000;
}
-#if QT_DEPRECATED_SINCE(5, 8)
-/*!
- \deprecated
-
- Returns the datetime as the number of seconds that have passed
- since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
-
- On systems that do not support time zones, this function will
- behave as if local time were Qt::UTC.
-
- \note This function returns a 32-bit unsigned integer and is deprecated.
-
- If the date is outside the range 1970-01-01T00:00:00 to
- 2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer
- (i.e., 0xFFFFFFFF).
-
- To get an extended range, use toMSecsSinceEpoch() or toSecsSinceEpoch().
-
- \sa toSecsSinceEpoch(), toMSecsSinceEpoch(), setTime_t()
-*/
-
-uint QDateTime::toTime_t() const
-{
- if (!isValid())
- return uint(-1);
- qint64 retval = toMSecsSinceEpoch() / 1000;
- if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
- return uint(-1);
- return uint(retval);
-}
-#endif
-
/*!
\since 4.7
@@ -4381,27 +4056,6 @@ void QDateTime::setSecsSinceEpoch(qint64 secs)
setMSecsSinceEpoch(secs * 1000);
}
-#if QT_DEPRECATED_SINCE(5, 8)
-/*!
- \fn void QDateTime::setTime_t(uint seconds)
- \deprecated
-
- Sets the date and time given the number of \a seconds that have
- passed since 1970-01-01T00:00:00, Coordinated Universal Time
- (Qt::UTC). On systems that do not support time zones this function
- will behave as if local time were Qt::UTC.
-
- \note This function is deprecated. For new code, use setSecsSinceEpoch().
-
- \sa toTime_t()
-*/
-
-void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
-{
- setMSecsSinceEpoch((qint64)secsSince1Jan1970UTC * 1000);
-}
-#endif
-
#if QT_CONFIG(datestring) // depends on, so implies, textdate
/*!
\overload
@@ -4998,7 +4652,7 @@ bool QDateTime::operator<(const QDateTime &other) const
Coordinated Time. This number is like the POSIX time_t variable, but
expressed in milliseconds instead.
- \sa currentDateTime(), currentDateTimeUtc(), toTime_t(), toTimeSpec()
+ \sa currentDateTime(), currentDateTimeUtc(), toTimeSpec()
*/
/*!
@@ -5119,69 +4773,6 @@ qint64 QDateTime::currentSecsSinceEpoch() noexcept
#error "What system is this?"
#endif
-#if QT_DEPRECATED_SINCE(5, 8)
-/*!
- \since 4.2
- \deprecated
-
- Returns a datetime whose date and time are the number of \a seconds
- that have passed since 1970-01-01T00:00:00, Coordinated Universal
- Time (Qt::UTC) and converted to Qt::LocalTime. On systems that do not
- support time zones, the time will be set as if local time were Qt::UTC.
-
- \note This function is deprecated. Please use fromSecsSinceEpoch() in new
- code.
-
- \sa toTime_t(), setTime_t()
-*/
-QDateTime QDateTime::fromTime_t(uint seconds)
-{
- return fromMSecsSinceEpoch((qint64)seconds * 1000, Qt::LocalTime);
-}
-
-/*!
- \since 5.2
- \deprecated
-
- Returns a datetime whose date and time are the number of \a seconds
- that have passed since 1970-01-01T00:00:00, Coordinated Universal
- Time (Qt::UTC) and converted to the given \a spec.
-
- If the \a spec is not Qt::OffsetFromUTC then the \a offsetSeconds will be
- ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0
- then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.
-
- \note This function is deprecated. Please use fromSecsSinceEpoch() in new
- code.
-
- \sa toTime_t(), setTime_t()
-*/
-QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSeconds)
-{
- return fromMSecsSinceEpoch((qint64)seconds * 1000, spec, offsetSeconds);
-}
-
-#if QT_CONFIG(timezone)
-/*!
- \since 5.2
- \deprecated
-
- Returns a datetime whose date and time are the number of \a seconds
- that have passed since 1970-01-01T00:00:00, Coordinated Universal
- Time (Qt::UTC) and with the given \a timeZone.
-
- \note This function is deprecated. Please use fromSecsSinceEpoch() in new
- code.
-
- \sa toTime_t(), setTime_t()
-*/
-QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
-{
- return fromMSecsSinceEpoch((qint64)seconds * 1000, timeZone);
-}
-#endif
-#endif // QT_DEPRECATED_SINCE(5, 8)
-
/*!
\since 4.7
@@ -5288,42 +4879,6 @@ QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone)
}
#endif
-#if QT_DEPRECATED_SINCE(5, 2)
-/*!
- \since 4.4
- \internal
- \obsolete
-
- This method was added in 4.4 but never documented as public. It was replaced
- in 5.2 with public method setOffsetFromUtc() for consistency with QTimeZone.
-
- This method should never be made public.
-
- \sa setOffsetFromUtc()
- */
-void QDateTime::setUtcOffset(int seconds)
-{
- setOffsetFromUtc(seconds);
-}
-
-/*!
- \since 4.4
- \internal
- \obsolete
-
- This method was added in 4.4 but never documented as public. It was replaced
- in 5.1 with public method offsetFromUTC() for consistency with QTimeZone.
-
- This method should never be made public.
-
- \sa offsetFromUTC()
-*/
-int QDateTime::utcOffset() const
-{
- return offsetFromUtc();
-}
-#endif // QT_DEPRECATED_SINCE
-
#if QT_CONFIG(datestring) // depends on, so implies, textdate
/*!
diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h
index 52524f70a4..974627b704 100644
--- a/src/corelib/time/qdatetime.h
+++ b/src/corelib/time/qdatetime.h
@@ -60,12 +60,6 @@ class QDateTime;
class Q_CORE_EXPORT QDate // ### Qt 6: change to be used by value, not const &
{
-public:
- enum MonthNameType { // ### Qt 6: remove, along with methods using it
- DateFormat = 0,
- StandaloneFormat
- };
-private:
explicit Q_DECL_CONSTEXPR QDate(qint64 julianDay) : jd(julianDay) {}
public:
Q_DECL_CONSTEXPR QDate() : jd(nullJd()) {}
@@ -99,16 +93,6 @@ public:
QDateTime endOfDay(const QTimeZone &zone) const;
#endif
-#if QT_DEPRECATED_SINCE(5, 10) && QT_CONFIG(textdate)
- QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName")
- static QString shortMonthName(int month, MonthNameType type = DateFormat);
- QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName")
- static QString shortDayName(int weekday, MonthNameType type = DateFormat);
- QT_DEPRECATED_X("Use QLocale::monthName or QLocale::standaloneMonthName")
- static QString longMonthName(int month, MonthNameType type = DateFormat);
- QT_DEPRECATED_X("Use QLocale::dayName or QLocale::standaloneDayName")
- static QString longDayName(int weekday, MonthNameType type = DateFormat);
-#endif // textdate && deprecated
#if QT_CONFIG(datestring)
QString toString(Qt::DateFormat format = Qt::TextDate) const;
#if QT_DEPRECATED_SINCE(5, 15)
@@ -125,17 +109,9 @@ public:
QString toString(QStringView format) const;
QString toString(QStringView format, QCalendar cal) const;
#endif
-#if QT_DEPRECATED_SINCE(5,0)
- QT_DEPRECATED_X("Use setDate() instead") 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);
bool setDate(int year, int month, int day, QCalendar cal);
-#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- void getDate(int *year, int *month, int *day); // ### Qt 6: remove
-#endif // < Qt 6
void getDate(int *year, int *month, int *day) const;
Q_REQUIRED_RESULT QDate addDays(qint64 days) const;
@@ -229,11 +205,6 @@ public:
#endif
static bool isValid(int h, int m, int s, int ms = 0);
-#if QT_DEPRECATED_SINCE(5, 14) // ### Qt 6: remove
- QT_DEPRECATED_X("Use QElapsedTimer instead") void start();
- QT_DEPRECATED_X("Use QElapsedTimer instead") int restart();
- QT_DEPRECATED_X("Use QElapsedTimer instead") int elapsed() const;
-#endif
private:
enum TimeFlag { NullTime = -1 };
Q_DECL_CONSTEXPR inline int ds() const { return mds == -1 ? 0 : mds; }
@@ -292,9 +263,6 @@ class Q_CORE_EXPORT QDateTime
public:
QDateTime() noexcept(Data::CanBeSmall);
-#if QT_DEPRECATED_SINCE(5, 15) // ### Qt 6: remove
- QT_DEPRECATED_X("Use QDate::startOfDay()") explicit QDateTime(QDate);
-#endif
QDateTime(QDate date, QTime time, Qt::TimeSpec spec = Qt::LocalTime, int offsetSeconds = 0);
#if QT_CONFIG(timezone)
QDateTime(QDate date, QTime time, const QTimeZone &timeZone);
@@ -368,11 +336,6 @@ public:
inline bool operator>(const QDateTime &other) const { return other < *this; }
inline bool operator>=(const QDateTime &other) const { return !(*this < other); }
-#if QT_DEPRECATED_SINCE(5, 2) // ### Qt 6: remove
- QT_DEPRECATED_X("Use setOffsetFromUtc() instead") void setUtcOffset(int seconds);
- QT_DEPRECATED_X("Use offsetFromUtc() instead") int utcOffset() const;
-#endif // QT_DEPRECATED_SINCE
-
static QDateTime currentDateTime();
static QDateTime currentDateTimeUtc();
#if QT_CONFIG(datestring)
@@ -381,15 +344,6 @@ public:
static QDateTime fromString(const QString &s, const QString &format, QCalendar cal);
#endif
-#if QT_DEPRECATED_SINCE(5, 8)
- uint toTime_t() const;
- void setTime_t(uint secsSince1Jan1970UTC);
- static QDateTime fromTime_t(uint secsSince1Jan1970UTC);
- static QDateTime fromTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec,
- int offsetFromUtc = 0);
- static QDateTime fromTime_t(uint secsSince1Jan1970UTC, const QTimeZone &timeZone);
-#endif
-
static QDateTime fromMSecsSinceEpoch(qint64 msecs);
// ### Qt 6: Merge with above with default spec = Qt::LocalTime
static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
diff --git a/tests/auto/corelib/time/qdate/tst_qdate.cpp b/tests/auto/corelib/time/qdate/tst_qdate.cpp
index 402c2c74d4..cc0c9fb894 100644
--- a/tests/auto/corelib/time/qdate/tst_qdate.cpp
+++ b/tests/auto/corelib/time/qdate/tst_qdate.cpp
@@ -91,16 +91,6 @@ private slots:
void printNegativeYear_data() const;
void printNegativeYear() const;
void roundtripGermanLocale() const;
-#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10)
- void shortDayName() const;
- void standaloneShortDayName() const;
- void longDayName() const;
- void standaloneLongDayName() const;
- void shortMonthName() const;
- void standaloneShortMonthName() const;
- void longMonthName() const;
- void standaloneLongMonthName() const;
-#endif // textdate
void roundtrip() const;
void qdebug() const;
private:
@@ -1436,16 +1426,6 @@ 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);
- QCOMPARE(dt.year(), 1901);
- QCOMPARE(dt.month(), 2);
- QCOMPARE(dt.day(), 3);
- }
-#endif
-
{
QDate dt;
dt.setDate(1, 2, 3);
@@ -1492,140 +1472,6 @@ void tst_QDate::roundtripGermanLocale() const
theDateTime.fromString(theDateTime.toString(Qt::TextDate), Qt::TextDate);
}
-#if QT_CONFIG(textdate) && QT_DEPRECATED_SINCE(5, 10)
-QT_WARNING_PUSH // the methods tested here are all deprecated
-QT_WARNING_DISABLE_GCC("-Wdeprecated-declarations")
-
-void tst_QDate::shortDayName() const
-{
- QCOMPARE(QDate::shortDayName(0), QString());
- QCOMPARE(QDate::shortDayName(8), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::shortDayName(1), QLatin1String("Mon"));
- QCOMPARE(QDate::shortDayName(7), QLatin1String("Sun"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 7; ++i) {
- QCOMPARE(QDate::shortDayName(i), locale.dayName(i, QLocale::ShortFormat));
- }
-}
-
-void tst_QDate::standaloneShortDayName() const
-{
- QCOMPARE(QDate::shortDayName(0, QDate::StandaloneFormat), QString());
- QCOMPARE(QDate::shortDayName(8, QDate::StandaloneFormat), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::shortDayName(1, QDate::StandaloneFormat), QLatin1String("Mon"));
- QCOMPARE(QDate::shortDayName(7, QDate::StandaloneFormat), QLatin1String("Sun"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 7; ++i) {
- QCOMPARE(QDate::shortDayName(i, QDate::StandaloneFormat), locale.standaloneDayName(i, QLocale::ShortFormat));
- }
-}
-
-void tst_QDate::longDayName() const
-{
- QCOMPARE(QDate::longDayName(0), QString());
- QCOMPARE(QDate::longDayName(8), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::longDayName(1), QLatin1String("Monday"));
- QCOMPARE(QDate::longDayName(7), QLatin1String("Sunday"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 7; ++i) {
- QCOMPARE(QDate::longDayName(i), locale.dayName(i, QLocale::LongFormat));
- }
-}
-
-void tst_QDate::standaloneLongDayName() const
-{
- QCOMPARE(QDate::longDayName(0, QDate::StandaloneFormat), QString());
- QCOMPARE(QDate::longDayName(8, QDate::StandaloneFormat), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::longDayName(1, QDate::StandaloneFormat), QLatin1String("Monday"));
- QCOMPARE(QDate::longDayName(7, QDate::StandaloneFormat), QLatin1String("Sunday"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 7; ++i) {
- QCOMPARE(QDate::longDayName(i, QDate::StandaloneFormat), locale.standaloneDayName(i, QLocale::LongFormat));
- }
-}
-
-void tst_QDate::shortMonthName() const
-{
- QCOMPARE(QDate::shortMonthName(0), QString());
- QCOMPARE(QDate::shortMonthName(13), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::shortMonthName(1), QLatin1String("Jan"));
- QCOMPARE(QDate::shortMonthName(8), QLatin1String("Aug"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 12; ++i) {
- QCOMPARE(QDate::shortMonthName(i), locale.monthName(i, QLocale::ShortFormat));
- }
-}
-
-void tst_QDate::standaloneShortMonthName() const
-{
- QCOMPARE(QDate::shortMonthName(0, QDate::StandaloneFormat), QString());
- QCOMPARE(QDate::shortMonthName(13, QDate::StandaloneFormat), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::shortMonthName(1, QDate::StandaloneFormat), QLatin1String("Jan"));
- QCOMPARE(QDate::shortMonthName(8, QDate::StandaloneFormat), QLatin1String("Aug"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 12; ++i) {
- QCOMPARE(QDate::shortMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::ShortFormat));
- }
-}
-
-void tst_QDate::longMonthName() const
-{
- QCOMPARE(QDate::longMonthName(0), QString());
- QCOMPARE(QDate::longMonthName(13), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::longMonthName(1), QLatin1String("January"));
- QCOMPARE(QDate::longMonthName(8), QLatin1String("August"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 12; ++i) {
- QCOMPARE(QDate::longMonthName(i), locale.monthName(i, QLocale::LongFormat));
- }
-}
-
-void tst_QDate::standaloneLongMonthName() const
-{
- QCOMPARE(QDate::longMonthName(0, QDate::StandaloneFormat), QString());
- QCOMPARE(QDate::longMonthName(13, QDate::StandaloneFormat), QString());
-
- if (QLocale::system().language() == QLocale::C) {
- QCOMPARE(QDate::longMonthName(1, QDate::StandaloneFormat), QLatin1String("January"));
- QCOMPARE(QDate::longMonthName(8, QDate::StandaloneFormat), QLatin1String("August"));
- }
-
- QLocale locale = QLocale::system();
- for(int i = 1; i <= 12; ++i) {
- QCOMPARE(QDate::longMonthName(i, QDate::StandaloneFormat), locale.standaloneMonthName(i, QLocale::LongFormat));
- }
-}
-QT_WARNING_POP
-#endif // textdate
-
void tst_QDate::roundtrip() const
{
// Test round trip, this exercises setDate(), isValid(), isLeapYear(),
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 07f83d1a63..65e12c1171 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -61,10 +61,6 @@ private slots:
void timeSpec();
void toSecsSinceEpoch_data();
void toSecsSinceEpoch();
-#if QT_DEPRECATED_SINCE(5, 8)
- void toTime_t_data();
- void toTime_t();
-#endif
void daylightSavingsTimeChange_data();
void daylightSavingsTimeChange();
void springForward_data();
@@ -1710,39 +1706,6 @@ void tst_QDateTime::toSecsSinceEpoch()
}
}
-#if QT_DEPRECATED_SINCE(5, 8)
-void tst_QDateTime::toTime_t_data()
-{
- QTest::addColumn<QString>("dateTimeStr");
- QTest::addColumn<bool>("res");
-
- QTest::newRow( "data1" ) << str( 1800, 1, 1, 12, 0, 0 ) << false;
- QTest::newRow( "data2" ) << str( 1969, 1, 1, 12, 0, 0 ) << false;
- QTest::newRow( "data3" ) << str( 2002, 1, 1, 12, 0, 0 ) << true;
- QTest::newRow( "data4" ) << str( 2002, 6, 1, 12, 0, 0 ) << true;
- QTest::newRow( "data5" ) << QString("INVALID") << false;
- QTest::newRow( "data6" ) << str( 2038, 1, 1, 12, 0, 0 ) << true;
- QTest::newRow( "data7" ) << str( 2063, 4, 5, 12, 0, 0 ) << true; // the day of First Contact
- QTest::newRow( "data8" ) << str( 2107, 1, 1, 12, 0, 0 )
- << bool( sizeof(uint) > 32 && sizeof(time_t) > 32 );
-}
-
-void tst_QDateTime::toTime_t()
-{
- QFETCH( QString, dateTimeStr );
- QDateTime datetime = dt( dateTimeStr );
-
- uint asTime_t = datetime.toTime_t();
- QFETCH( bool, res );
- if (res) {
- QVERIFY(asTime_t != uint(-1));
- QCOMPARE(QDateTime::fromTime_t(asTime_t), datetime);
- } else {
- QCOMPARE(asTime_t, uint(-1));
- }
-}
-#endif
-
void tst_QDateTime::daylightSavingsTimeChange_data()
{
QTest::addColumn<QDate>("inDST");
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm b/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm
index f73c7b9d5d..4af199b4f8 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime_mac.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2014 Petroules Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -49,7 +49,7 @@ void tst_QDateTime_macTypes()
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
const CFDateRef cfDate = qtDateTime.toCFDate();
QDateTime qtDateTimeCopy(qtDateTime);
- qtDateTime.setTime_t(10000); // modify
+ qtDateTime.setSecsSinceEpoch(10000); // modify
QCOMPARE(QDateTime::fromCFDate(cfDate), qtDateTimeCopy);
}
// QDateTime <-> NSDate
@@ -64,7 +64,7 @@ void tst_QDateTime_macTypes()
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
const NSDate *nsDate = qtDateTime.toNSDate();
QDateTime qtDateTimeCopy(qtDateTime);
- qtDateTime.setTime_t(10000); // modify
+ qtDateTime.setSecsSinceEpoch(10000); // modify
QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTimeCopy);
}
}