diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-08-17 18:34:09 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-08-22 09:47:22 +0000 |
commit | b6a61211280aa6ddd56f107a9795c9824b7702b0 (patch) | |
tree | 98e7dc1660a9d88a9b12d51b764501369169a866 /src/corelib/tools/qdatetime.cpp | |
parent | 8b3a120a3b05803494d4e06edb5a8f4ee5d080f6 (diff) |
Deprecate QDate methods using MonthNameType
These introduce an unwanted locale-dependency; clients should use
suitable QLocale methods instead.
Task-number: QTBUG-28581
Change-Id: Ie7dfe712c50b9f5da94e4b20af7b231d8963cbc9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qdatetime.cpp')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index d8d79dfeba..056dff5442 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -193,7 +193,7 @@ static int fromShortMonthName(const QStringRef &monthName) return month; // If English names can't be found, search the localized ones for (int i = 1; i <= 12; ++i) { - if (monthName == QDate::shortMonthName(i)) + if (monthName == QLocale::system().monthName(i, QLocale::ShortFormat)) return i; } return -1; @@ -611,9 +611,10 @@ int QDate::weekNumber(int *yearNumber) const return week; } -#ifndef QT_NO_TEXTDATE +#if QT_DEPRECATED_SINCE(5, 11) && !defined(QT_NO_TEXTDATE) /*! \since 4.5 + \deprecated Returns the short name of the \a month for the representation specified by \a type. @@ -656,6 +657,7 @@ QString QDate::shortMonthName(int month, QDate::MonthNameType type) /*! \since 4.5 + \deprecated Returns the long name of the \a month for the representation specified by \a type. @@ -698,6 +700,7 @@ QString QDate::longMonthName(int month, MonthNameType type) /*! \since 4.5 + \deprecated Returns the short name of the \a weekday for the representation specified by \a type. @@ -735,6 +738,7 @@ QString QDate::shortDayName(int weekday, MonthNameType type) /*! \since 4.5 + \deprecated Returns the long name of the \a weekday for the representation specified by \a type. @@ -769,7 +773,7 @@ QString QDate::longDayName(int weekday, MonthNameType type) } return QString(); } -#endif //QT_NO_TEXTDATE +#endif // QT_NO_TEXTDATE && deprecated #ifndef QT_NO_DATESTRING @@ -778,8 +782,8 @@ static QString toStringTextDate(QDate date) { const ParsedDate pd = getDateFromJulianDay(date.toJulianDay()); static const QLatin1Char sp(' '); - return date.shortDayName(date.dayOfWeek()) + sp - + date.shortMonthName(pd.month) + sp + return QLocale::system().dayName(date.dayOfWeek(), QLocale::ShortFormat) + sp + + QLocale::system().monthName(pd.month, QLocale::ShortFormat) + sp + QString::number(pd.day) + sp + QString::number(pd.year); } |