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>
This commit is contained in:
Thiago Macieira 2017-06-13 10:10:06 -07:00
parent fffbdb4c37
commit e7f962d271

View File

@ -645,14 +645,12 @@ 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);
}
}
return QString();
}
@ -689,14 +687,12 @@ 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);
}
}
return QString();
}
@ -728,14 +724,12 @@ 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);
}
}
return QString();
}
@ -767,14 +761,12 @@ 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);
}
}
return QString();
}
#endif //QT_NO_TEXTDATE