diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-13 10:10:06 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-20 16:37:47 +0000 |
commit | e7f962d2719fb5d44b24a58b9d493ade93538cf4 (patch) | |
tree | 1444e2d075b7a701dd201d88f8c80d3b0429da7f | |
parent | fffbdb4c374333c6660ef2265f636edbd2903b87 (diff) |
QDate::shortMonthName: remove faulty month test
QLocale already takes care of validating the month inputs, so no need to
spend cycles and binary size for the invalid case.
This commit also removes the check from QDate::longMonthName and the day
name functions so that all functions remain similar.
Task-number: QTBUG-61399
Change-Id: Ia53158e207a94bf49489fffd14c7bd8b121dd132
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index b6f43f0864..5677f35bc9 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -645,13 +645,11 @@ int QDate::weekNumber(int *yearNumber) const QString QDate::shortMonthName(int month, QDate::MonthNameType type) { - if (month >= 1 || month <= 12) { - switch (type) { - case QDate::DateFormat: - return QLocale::system().monthName(month, QLocale::ShortFormat); - case QDate::StandaloneFormat: - return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat); - } + switch (type) { + case QDate::DateFormat: + return QLocale::system().monthName(month, QLocale::ShortFormat); + case QDate::StandaloneFormat: + return QLocale::system().standaloneMonthName(month, QLocale::ShortFormat); } return QString(); } @@ -689,13 +687,11 @@ QString QDate::shortMonthName(int month, QDate::MonthNameType type) QString QDate::longMonthName(int month, MonthNameType type) { - if (month >= 1 && month <= 12) { - switch (type) { - case QDate::DateFormat: - return QLocale::system().monthName(month, QLocale::LongFormat); - case QDate::StandaloneFormat: - return QLocale::system().standaloneMonthName(month, QLocale::LongFormat); - } + switch (type) { + case QDate::DateFormat: + return QLocale::system().monthName(month, QLocale::LongFormat); + case QDate::StandaloneFormat: + return QLocale::system().standaloneMonthName(month, QLocale::LongFormat); } return QString(); } @@ -728,13 +724,11 @@ QString QDate::longMonthName(int month, MonthNameType type) QString QDate::shortDayName(int weekday, MonthNameType type) { - if (weekday >= 1 && weekday <= 7) { - switch (type) { - case QDate::DateFormat: - return QLocale::system().dayName(weekday, QLocale::ShortFormat); - case QDate::StandaloneFormat: - return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat); - } + switch (type) { + case QDate::DateFormat: + return QLocale::system().dayName(weekday, QLocale::ShortFormat); + case QDate::StandaloneFormat: + return QLocale::system().standaloneDayName(weekday, QLocale::ShortFormat); } return QString(); } @@ -767,13 +761,11 @@ QString QDate::shortDayName(int weekday, MonthNameType type) QString QDate::longDayName(int weekday, MonthNameType type) { - if (weekday >= 1 && weekday <= 7) { - switch (type) { - case QDate::DateFormat: - return QLocale::system().dayName(weekday, QLocale::LongFormat); - case QDate::StandaloneFormat: - return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat); - } + switch (type) { + case QDate::DateFormat: + return QLocale::system().dayName(weekday, QLocale::LongFormat); + case QDate::StandaloneFormat: + return QLocale::system().standaloneDayName(weekday, QLocale::LongFormat); } return QString(); } |