Fix QDateEdit displaying day as a number for short and long day formats
authorMitch Curtis <mitch.curtis@nokia.com>
Wed, 29 Aug 2012 10:58:35 +0000 (12:58 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 5 Sep 2012 19:06:51 +0000 (21:06 +0200)
When 2 (February) is entered as the month for (e.g.) 31/Jan/2000 (which
is following the format: "dd/MMM/yyyy"), the day is corrected to 29 but
displayed as its numerical value instead of its short (or long) name.

Task-number: QTBUG-27036 QTBUG-19091
Change-Id: I558ee13b224707d22b26c2ec2c045f96118bd5a1
Reviewed-by: Mitch Curtis <mitch.curtis@nokia.com>
Reviewed-by: aavit <qt_aavit@ovi.com>
src/corelib/tools/qdatetime.cpp
src/corelib/tools/qdatetime_p.h
src/widgets/widgets/qdatetimeedit.cpp
tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp

index 421e6db..cbbf31b 100644 (file)
@@ -4188,7 +4188,8 @@ int QDateTimeParser::getDigit(const QDateTime &t, int index) const
     case YearSection: return t.date().year();
     case MonthSection: return t.date().month();
     case DaySection: return t.date().day();
-    case DayOfWeekSection: return t.date().day();
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong: return t.date().day();
     case AmPmSection: return t.time().hour() > 11 ? 1 : 0;
 
     default: break;
@@ -4246,7 +4247,8 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
     case YearSection: year = newVal; break;
     case MonthSection: month = newVal; break;
     case DaySection:
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
         if (newVal > 31) {
             // have to keep legacy behavior. setting the
             // date to 32 should return false. Setting it
@@ -4262,7 +4264,7 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const
         break;
     }
 
-    if (!(node.type & (DaySection|DayOfWeekSection))) {
+    if (!(node.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
         if (day < cachedDay)
             day = cachedDay;
         const int max = QDate(year, month, 1).daysInMonth();
@@ -4303,7 +4305,8 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const
                                    // stepBy() will work on real years anyway
     case MonthSection: return 12;
     case DaySection:
-    case DayOfWeekSection: return cur.isValid() ? cur.date().daysInMonth() : 31;
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong: return cur.isValid() ? cur.date().daysInMonth() : 31;
     case AmPmSection: return 1;
     default: break;
     }
@@ -4331,7 +4334,8 @@ int QDateTimeParser::absoluteMin(int s) const
     case YearSection: return 0;
     case MonthSection:
     case DaySection:
-    case DayOfWeekSection: return 1;
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong: return 1;
     case AmPmSection: return 0;
     default: break;
     }
@@ -4573,7 +4577,9 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
             case 'd':
                 if (parserType != QVariant::Time) {
                     const int repeat = countRepeat(newFormat, i, 4);
-                    const SectionNode sn = { repeat >= 3 ? DayOfWeekSection : DaySection, i - add, repeat, 0 };
+                    const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
+                        : (repeat == 3 ? DayOfWeekSectionShort : DaySection));
+                    const SectionNode sn = { sectionType, i - add, repeat, 0 };
                     newSectionNodes.append(sn);
                     appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
                     i += sn.count - 1;
@@ -4688,7 +4694,8 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
     case MinuteSection:
     case SecondSection:
     case DaySection: return 2;
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
 #ifdef QT_NO_TEXTDATE
         return 2;
 #else
@@ -4843,7 +4850,8 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
         }
         break; }
     case MonthSection:
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
         if (sn.count >= 3) {
             if (sn.type == MonthSection) {
                 int min = 1;
@@ -5049,7 +5057,8 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
                 case YearSection: current = &year; break;
                 case YearSection2Digits: current = &year2digits; break;
                 case MonthSection: current = &month; break;
-                case DayOfWeekSection: current = &dayofweek; break;
+                case DayOfWeekSectionShort:
+                case DayOfWeekSectionLong: current = &dayofweek; break;
                 case DaySection: current = &day; num = qMax<int>(1, num); break;
                 case AmPmSection: current = &ampm; break;
                 default:
@@ -5103,10 +5112,10 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
 
                 const QDate date(year, month, day);
                 const int diff = dayofweek - date.dayOfWeek();
-                if (diff != 0 && state == Acceptable && isSet & DayOfWeekSection) {
+                if (diff != 0 && state == Acceptable && isSet & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
                     conflicts = isSet & DaySection;
                     const SectionNode &sn = sectionNode(currentSectionIndex);
-                    if (sn.type == DayOfWeekSection || currentSectionIndex == -1) {
+                    if (sn.type & (DayOfWeekSectionShort|DayOfWeekSectionLong) || currentSectionIndex == -1) {
                         // dayofweek should be preferred
                         day += diff;
                         if (day <= 0) {
@@ -5119,7 +5128,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
                     }
                 }
                 bool needfixday = false;
-                if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSection)) {
+                if (sectionType(currentSectionIndex) & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) {
                     cachedDay = day;
                 } else if (cachedDay > day) {
                     day = cachedDay;
@@ -5144,8 +5153,15 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
 
                         const QLocale loc = locale();
                         for (int i=0; i<sectionNodesCount; ++i) {
-                            if (sectionType(i) & (DaySection|DayOfWeekSection)) {
+                            const Section thisSectionType = sectionType(i);
+                            if (thisSectionType & (DaySection)) {
                                 input.replace(sectionPos(i), sectionSize(i), loc.toString(day));
+                            } else if (thisSectionType & (DayOfWeekSectionShort|DayOfWeekSectionLong)) {
+                                const int dayOfWeek = QDate(year, month, day).dayOfWeek();
+                                const QLocale::FormatType dayFormat = (thisSectionType == DayOfWeekSectionShort
+                                    ? QLocale::ShortFormat : QLocale::LongFormat);
+                                const QString dayName(loc.dayName(dayOfWeek, dayFormat));
+                                input.replace(sectionPos(i), sectionSize(i), dayName);
                             }
                         }
                     } else {
@@ -5396,7 +5412,7 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
     int bestCount = 0;
     if (!str1.isEmpty()) {
         const SectionNode &sn = sectionNode(sectionIndex);
-        if (!(sn.type & (DaySection|DayOfWeekSection))) {
+        if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
             qWarning("QDateTimeParser::findDay Internal error");
             return -1;
         }
@@ -5554,7 +5570,8 @@ int QDateTimeParser::maxChange(int index) const
     case Hour24Section: case Hour12Section: return 59 * 60 * 60 * 1000;
 
         // Date. unit is day
-    case DayOfWeekSection: return 7;
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong: return 7;
     case DaySection: return 30;
     case MonthSection: return 365 - 31;
     case YearSection: return 9999 * 365;
@@ -5601,7 +5618,8 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const
             break;
         }
         break;
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
         if (sn.count == 3)
             ret |= FixedWidth;
         break;
@@ -5640,7 +5658,8 @@ QString QDateTimeParser::sectionFormat(Section s, int count) const
     case MinuteSection: fillChar = QLatin1Char('m'); break;
     case Hour24Section: fillChar = QLatin1Char('H'); break;
     case Hour12Section: fillChar = QLatin1Char('h'); break;
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
     case DaySection: fillChar = QLatin1Char('d'); break;
     case MonthSection: fillChar = QLatin1Char('M'); break;
     case YearSection2Digits:
@@ -5750,7 +5769,8 @@ QString QDateTimeParser::sectionName(int s) const
     switch (s) {
     case QDateTimeParser::AmPmSection: return QLatin1String("AmPmSection");
     case QDateTimeParser::DaySection: return QLatin1String("DaySection");
-    case QDateTimeParser::DayOfWeekSection: return QLatin1String("DayOfWeekSection");
+    case QDateTimeParser::DayOfWeekSectionShort: return QLatin1String("DayOfWeekSectionShort");
+    case QDateTimeParser::DayOfWeekSectionLong: return QLatin1String("DayOfWeekSectionLong");
     case QDateTimeParser::Hour24Section: return QLatin1String("Hour24Section");
     case QDateTimeParser::Hour12Section: return QLatin1String("Hour12Section");
     case QDateTimeParser::MSecSection: return QLatin1String("MSecSection");
index ce8be86..07dcc00 100644 (file)
@@ -154,8 +154,9 @@ public:
         MonthSection = 0x00200,
         YearSection = 0x00400,
         YearSection2Digits = 0x00800,
-        DayOfWeekSection = 0x01000,
-        DateSectionMask = (DaySection|MonthSection|YearSection|YearSection2Digits|DayOfWeekSection),
+        DayOfWeekSectionShort = 0x01000,
+        DayOfWeekSectionLong = 0x20000,
+        DateSectionMask = (DaySection|MonthSection|YearSection|YearSection2Digits|DayOfWeekSectionShort|DayOfWeekSectionLong),
         FirstSection = 0x02000|Internal,
         LastSection = 0x04000|Internal,
         CalendarPopupSection = 0x08000|Internal,
index b339e04..82edb4b 100644 (file)
@@ -2046,7 +2046,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c
             // doesn't mean that we hit the floor in the other
             if (steps > 0) {
                 setDigit(v, sectionIndex, min);
-                if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) {
+                if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) {
                     const int daysInMonth = v.date().daysInMonth();
                     if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
                         const int adds = qMin(oldDay, daysInMonth);
@@ -2061,7 +2061,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c
                 }
             } else {
                 setDigit(v, sectionIndex, max);
-                if (!(sn.type & (DaySection|DayOfWeekSection)) && sections & DateSectionMask) {
+                if (!(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong)) && sections & DateSectionMask) {
                     const int daysInMonth = v.date().daysInMonth();
                     if (v.date().day() < oldDay && v.date().day() < daysInMonth) {
                         const int adds = qMin(oldDay, daysInMonth);
@@ -2079,7 +2079,7 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c
             setDigit(v, sectionIndex, (steps > 0 ? localmax : localmin));
         }
     }
-    if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSection))) {
+    if (!test && oldDay != v.date().day() && !(sn.type & (DaySection|DayOfWeekSectionShort|DayOfWeekSectionLong))) {
         // this should not happen when called from stepEnabled
         cachedDay = qMax<int>(oldDay, cachedDay);
     }
@@ -2247,7 +2247,8 @@ QDateTimeEdit::Section QDateTimeEditPrivate::convertToPublic(QDateTimeParser::Se
     case MSecSection: return QDateTimeEdit::MSecSection;
     case SecondSection: return QDateTimeEdit::SecondSection;
     case MinuteSection: return QDateTimeEdit::MinuteSection;
-    case DayOfWeekSection:
+    case DayOfWeekSectionShort:
+    case DayOfWeekSectionLong:
     case DaySection: return QDateTimeEdit::DaySection;
     case MonthSection: return QDateTimeEdit::MonthSection;
     case YearSection2Digits:
@@ -2274,7 +2275,7 @@ QDateTimeEdit::Sections QDateTimeEditPrivate::convertSections(QDateTimeParser::S
         ret |= QDateTimeEdit::HourSection;
     if (s & QDateTimeParser::AmPmSection)
         ret |= QDateTimeEdit::AmPmSection;
-    if (s & (QDateTimeParser::DaySection|QDateTimeParser::DayOfWeekSection))
+    if (s & (QDateTimeParser::DaySection|QDateTimeParser::DayOfWeekSectionShort|QDateTimeParser::DayOfWeekSectionLong))
         ret |= QDateTimeEdit::DaySection;
     if (s & QDateTimeParser::MonthSection)
         ret |= QDateTimeEdit::MonthSection;
index e185e0a..269d5b1 100644 (file)
@@ -3498,6 +3498,7 @@ void tst_QDateTimeEdit::deleteCalendarWidget()
 typedef QPair<Qt::Key, Qt::KeyboardModifier> KeyPair;
 typedef QList<KeyPair> KeyPairList;
 
+Q_DECLARE_METATYPE(QLocale)
 Q_DECLARE_METATYPE(KeyPair)
 Q_DECLARE_METATYPE(KeyPairList)
 
@@ -3519,12 +3520,14 @@ focus changed.
 
 void tst_QDateTimeEdit::dateEditCorrectSectionSize_data()
 {
+    QTest::addColumn<QLocale>("locale");
     QTest::addColumn<QDate>("defaultDate");
     QTest::addColumn<QString>("displayFormat");
     QTest::addColumn<KeyPairList>("keyPresses");
     QTest::addColumn<QString>("expectedDisplayString");
 
     const QDate defaultDate(2000, 1, 1);
+    const QLocale defaultLocale(QLocale::English, QLocale::Australia);
 
     KeyPairList thirtyUpKeypresses;
     thirtyUpKeypresses.reserve(30);
@@ -3614,123 +3617,172 @@ void tst_QDateTimeEdit::dateEditCorrectSectionSize_data()
         << key(Qt::Key_3) << key(Qt::Key_1) << key(Qt::Key_Tab, Qt::ShiftModifier)
         << key(Qt::Key_Tab, Qt::ShiftModifier) << key(Qt::Key_Up);
 
-    QTest::newRow("fixday, leap, yy/MM/dd") << defaultDate << QString::fromLatin1("yy/MM/dd")
+    KeyPairList shortAndLongNameIssueKeypresses;
+    shortAndLongNameIssueKeypresses << key(Qt::Key_Tab) << key(Qt::Key_3) << key(Qt::Key_1) << key(Qt::Key_Up);
+
+    QTest::newRow("no fixday, leap, yy/M/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/M/dddd")
+        << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/2/Tuesday");
+
+    QTest::newRow("no fixday, leap, yy/M/ddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/M/ddd")
+        << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/2/Tue");
+
+    QTest::newRow("no fixday, leap, yy/MM/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/dddd")
+        << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("00/02/Tuesday");
+
+    QTest::newRow("fixday, leap, yy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/dd")
         << threeDigitDayIssueKeypresses << QString::fromLatin1("00/02/29");
 
-    QTest::newRow("fixday, leap, yy/MM/d") << defaultDate << QString::fromLatin1("yy/MM/d")
+    QTest::newRow("fixday, leap, yy/MM/d") << defaultLocale << defaultDate << QString::fromLatin1("yy/MM/d")
         << threeDigitDayIssueKeypresses << QString::fromLatin1("00/02/29");
 
-    QTest::newRow("fixday, leap, yyyy/M/d") << defaultDate << QString::fromLatin1("yyyy/M/d")
+    QTest::newRow("fixday, leap, yyyy/M/d") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/d")
         << threeDigitDayIssueKeypresses << QString::fromLatin1("2000/2/29");
 
-    QTest::newRow("no fixday, yyyy/M/d") << defaultDate.addYears(1) << QString::fromLatin1("yyyy/M/d")
+    QTest::newRow("no fixday, yyyy/M/d") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("yyyy/M/d")
         << threeDigitDayIssueKeypresses_Nofixday << QString::fromLatin1("2001/2/28");
 
-    QTest::newRow("fixday, leap, 2-digit month, yyyy/M/dd") << defaultDate << QString::fromLatin1("yyyy/M/dd")
+    QTest::newRow("fixday, leap, 2-digit month, yyyy/M/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dd")
         << threeDigitDayIssueKeypresses_TwoDigitMonth << QString::fromLatin1("2000/11/30");
 
-    QTest::newRow("no fixday, leap, 1-digit day, yyyy/M/dd") << defaultDate << QString::fromLatin1("yyyy/M/dd")
+    QTest::newRow("no fixday, leap, 1-digit day, yyyy/M/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dd")
         << threeDigitDayIssueKeypresses_OneDigitDay << QString::fromLatin1("2000/2/03");
 
-    QTest::newRow("fixday, leap, yyyy/MM/dd") << defaultDate << QString::fromLatin1("yyyy/MM/dd")
+    QTest::newRow("fixday, leap, yyyy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dd")
         << threeDigitDayIssueKeypresses << QString::fromLatin1("2000/02/29");
 
-    QTest::newRow("no fixday, yyyy/MM/dd") << defaultDate.addYears(1) << QString::fromLatin1("yyyy/MM/dd")
+    QTest::newRow("no fixday, yyyy/MM/dd") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("yyyy/MM/dd")
         << threeDigitDayIssueKeypresses_Nofixday << QString::fromLatin1("2001/02/28");
 
-    QTest::newRow("fixday, leap, 2-digit month, yyyy/MM/dd") << defaultDate << QString::fromLatin1("yyyy/MM/dd")
+    QTest::newRow("fixday, leap, 2-digit month, yyyy/MM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dd")
         << threeDigitDayIssueKeypresses_TwoDigitMonth << QString::fromLatin1("2000/11/30");
 
-    QTest::newRow("fixday, leap, yyyy/dd/MM") << defaultDate << QString::fromLatin1("yyyy/dd/MM")
+    QTest::newRow("no fixday, leap, yyyy/M/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/M/dddd")
+        << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("2000/2/Tuesday");
+
+    QTest::newRow("no fixday, leap, yyyy/MM/dddd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MM/dddd")
+        << threeDigitDayIssueKeypresses_DayName << QString::fromLatin1("2000/02/Tuesday");
+
+    QTest::newRow("fixday, leap, yyyy/dd/MM") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dd/MM")
         << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/02");
 
-    QTest::newRow("fixday, leap, yyyy/dd/M") << defaultDate << QString::fromLatin1("yyyy/dd/M")
+    QTest::newRow("fixday, leap, yyyy/dd/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dd/M")
         << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/2");
 
-    QTest::newRow("fixday, leap, yyyy/d/M") << defaultDate << QString::fromLatin1("yyyy/d/M")
+    QTest::newRow("fixday, leap, yyyy/d/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/d/M")
         << threeDigitDayIssueKeypresses_YearDayMonth << QString::fromLatin1("2000/29/2");
 
-    QTest::newRow("fixday, leap, yyyy/MMM/dd") << defaultDate << QString::fromLatin1("yyyy/MMM/dd")
+    QTest::newRow("fixday, leap, yyyy/MMM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MMM/dd")
         << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("2000/Feb/29");
 
-    QTest::newRow("fixday, leap, yyyy/MMM/d") << defaultDate << QString::fromLatin1("yyyy/MMM/d")
+    QTest::newRow("fixday, leap, yyyy/MMM/d") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/MMM/d")
         << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("2000/Feb/29");
 
-    QTest::newRow("fixday, leap, yy/MMM/dd") << defaultDate << QString::fromLatin1("yy/MMM/dd")
+    QTest::newRow("fixday, leap, yy/MMM/dd") << defaultLocale << defaultDate << QString::fromLatin1("yy/MMM/dd")
         << threeDigitDayIssueKeypresses_ShortMonthName << QString::fromLatin1("00/Feb/29");
 
-    QTest::newRow("fixday, leap, d/M/yyyy") << defaultDate << QString::fromLatin1("d/M/yyyy")
+    QTest::newRow("fixday, leap, yyyy/dddd/M") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dddd/M")
+        << threeDigitDayIssueKeypresses_DayName_YearDayMonth << QString::fromLatin1("2000/Tuesday/2");
+
+    QTest::newRow("fixday, leap, yyyy/dddd/MM") << defaultLocale << defaultDate << QString::fromLatin1("yyyy/dddd/MM")
+        << threeDigitDayIssueKeypresses_DayName_YearDayMonth << QString::fromLatin1("2000/Tuesday/02");
+
+    QTest::newRow("fixday, leap, d/M/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("d/M/yyyy")
         << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("29/2/2000");
 
-    QTest::newRow("fixday, leap, dd/MM/yyyy") << defaultDate << QString::fromLatin1("dd/MM/yyyy")
+    QTest::newRow("fixday, leap, dd/MM/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("dd/MM/yyyy")
         << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("29/02/2000");
 
-    QTest::newRow("fixday, dd/MM/yyyy") << defaultDate.addYears(1) << QString::fromLatin1("dd/MM/yyyy")
+    QTest::newRow("fixday, dd/MM/yyyy") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("dd/MM/yyyy")
         << reverseThreeDigitDayIssueKeypresses << QString::fromLatin1("28/02/2001");
 
-    QTest::newRow("fixday, leap, d/yy/M") << defaultDate << QString::fromLatin1("d/yy/M")
+    QTest::newRow("fixday, leap, dddd/MM/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("dddd/MM/yyyy")
+        << threeDigitDayIssueKeypresses_DayName_DayMonthYear << QString::fromLatin1("Tuesday/02/2000");
+
+    QTest::newRow("fixday, leap, d/yy/M") << defaultLocale << defaultDate << QString::fromLatin1("d/yy/M")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/00/2");
 
-    QTest::newRow("fixday, leap, d/yyyy/M") << defaultDate << QString::fromLatin1("d/yyyy/M")
+    QTest::newRow("fixday, leap, d/yyyy/M") << defaultLocale << defaultDate << QString::fromLatin1("d/yyyy/M")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/2");
 
-    QTest::newRow("fixday, leap, d/yyyy/MM") << defaultDate << QString::fromLatin1("d/yyyy/MM")
+    QTest::newRow("fixday, leap, d/yyyy/MM") << defaultLocale << defaultDate << QString::fromLatin1("d/yyyy/MM")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/02");
 
-    QTest::newRow("fixday, leap, dd/yy/MM") << defaultDate << QString::fromLatin1("dd/yy/MM")
+    QTest::newRow("fixday, leap, dd/yy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dd/yy/MM")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/00/02");
 
-    QTest::newRow("fixday, leap, dd/yyyy/M") << defaultDate << QString::fromLatin1("dd/yyyy/M")
+    QTest::newRow("fixday, leap, dd/yyyy/M") << defaultLocale << defaultDate << QString::fromLatin1("dd/yyyy/M")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/2");
 
-    QTest::newRow("fixday, leap, dd/yyyy/MM") << defaultDate << QString::fromLatin1("dd/yyyy/MM")
+    QTest::newRow("fixday, leap, dd/yyyy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dd/yyyy/MM")
         << threeDigitDayIssueKeypresses_DayYearMonth << QString::fromLatin1("29/2000/02");
 
-    QTest::newRow("fixday, leap, M/d/yy") << defaultDate << QString::fromLatin1("M/d/yy")
+    QTest::newRow("fixday, leap, dddd/yy/M") << defaultLocale << defaultDate << QString::fromLatin1("dddd/yy/M")
+        << threeDigitDayIssueKeypresses_DayName_DayYearMonth << QString::fromLatin1("Tuesday/00/2");
+
+    QTest::newRow("fixday, leap, dddd/yy/MM") << defaultLocale << defaultDate << QString::fromLatin1("dddd/yy/MM")
+        << threeDigitDayIssueKeypresses_DayName_DayYearMonth << QString::fromLatin1("Tuesday/00/02");
+
+    QTest::newRow("fixday, leap, M/d/yy") << defaultLocale << defaultDate << QString::fromLatin1("M/d/yy")
         << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/00");
 
-    QTest::newRow("fixday, leap, M/d/yyyy") << defaultDate << QString::fromLatin1("M/d/yyyy")
+    QTest::newRow("fixday, leap, M/d/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/d/yyyy")
         << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/2000");
 
-    QTest::newRow("fixday, leap, M/dd/yyyy") << defaultDate << QString::fromLatin1("M/dd/yyyy")
+    QTest::newRow("fixday, leap, M/dd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/dd/yyyy")
         << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("2/29/2000");
 
-    QTest::newRow("fixday, leap, MM/dd/yyyy") << defaultDate << QString::fromLatin1("MM/dd/yyyy")
+    QTest::newRow("fixday, leap, M/dddd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("M/dddd/yyyy")
+        << threeDigitDayIssueKeypresses_DayName_MonthDayYear << QString::fromLatin1("2/Tuesday/2000");
+
+    QTest::newRow("fixday, leap, MM/dd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("MM/dd/yyyy")
         << threeDigitDayIssueKeypresses_MonthDayYear << QString::fromLatin1("02/29/2000");
 
-    QTest::newRow("fixday, leap, M/yyyy/dd") << defaultDate << QString::fromLatin1("M/yyyy/dd")
+    QTest::newRow("fixday, leap, MM/dddd/yyyy") << defaultLocale << defaultDate << QString::fromLatin1("MM/dddd/yyyy")
+        << threeDigitDayIssueKeypresses_DayName_MonthDayYear << QString::fromLatin1("02/Tuesday/2000");
+
+    QTest::newRow("fixday, leap, M/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("M/yyyy/dd")
         << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/2000/29");
 
-    QTest::newRow("fixday, leap, M/yy/dd") << defaultDate << QString::fromLatin1("M/yy/dd")
+    QTest::newRow("fixday, leap, M/yy/dd") << defaultLocale << defaultDate << QString::fromLatin1("M/yy/dd")
         << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/00/29");
 
-    QTest::newRow("fixday, leap, M/yy/d") << defaultDate << QString::fromLatin1("M/yy/d")
+    QTest::newRow("fixday, leap, M/yy/d") << defaultLocale << defaultDate << QString::fromLatin1("M/yy/d")
         << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("2/00/29");
 
-    QTest::newRow("fixday, leap, MM/yyyy/dd") << defaultDate << QString::fromLatin1("MM/yyyy/dd")
+    QTest::newRow("fixday, leap, MM/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("MM/yyyy/dd")
         << threeDigitDayIssueKeypresses_MonthYearDay << QString::fromLatin1("02/2000/29");
 
-    QTest::newRow("fixday, leap, MMM/yy/d") << defaultDate << QString::fromLatin1("MMM/yy/d")
+    QTest::newRow("fixday, leap, MMM/yy/d") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yy/d")
         << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/00/29");
 
-    QTest::newRow("fixday, leap, MMM/yyyy/d") << defaultDate << QString::fromLatin1("MMM/yyyy/d")
+    QTest::newRow("fixday, leap, MMM/yyyy/d") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yyyy/d")
         << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2000/29");
 
-    QTest::newRow("fixday, MMM/yyyy/d") << defaultDate.addYears(1) << QString::fromLatin1("MMM/yyyy/d")
+    QTest::newRow("fixday, MMM/yyyy/d") << defaultLocale << defaultDate.addYears(1) << QString::fromLatin1("MMM/yyyy/d")
         << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2001/28");
 
-    QTest::newRow("fixday, leap, MMM/yyyy/dd") << defaultDate << QString::fromLatin1("MMM/yyyy/dd")
+    QTest::newRow("fixday, leap, MMM/yyyy/dd") << defaultLocale << defaultDate << QString::fromLatin1("MMM/yyyy/dd")
         << threeDigitDayIssueKeypresses_ShortMonthName_MonthYearDay << QString::fromLatin1("Feb/2000/29");
+
+    QTest::newRow("fixday, leap, dddd, dd. MMMM yyyy") << defaultLocale
+        << defaultDate << QString::fromLatin1("dddd, dd. MMMM yyyy")
+        << shortAndLongNameIssueKeypresses << QString::fromLatin1("Tuesday, 29. February 2000");
+
+    QTest::newRow("fixday, leap, german, dddd, dd. MMMM yyyy") << QLocale(QLocale::German, QLocale::Germany)
+        << defaultDate << QString::fromLatin1("dddd, dd. MMMM yyyy")
+        << shortAndLongNameIssueKeypresses << QString::fromLatin1("Dienstag, 29. Februar 2000");
 }
 
 void tst_QDateTimeEdit::dateEditCorrectSectionSize()
 {
+    QFETCH(QLocale, locale);
     QFETCH(QDate, defaultDate);
     QFETCH(QString, displayFormat);
     QFETCH(KeyPairList, keyPresses);
     QFETCH(QString, expectedDisplayString);
 
     QDateEdit edit;
+    edit.setLocale(locale);
     edit.setDate(defaultDate);
     edit.setDisplayFormat(displayFormat);
     edit.show();