Fix 3 digit day being displayed by QDateEdit.
authorMitch Curtis <mitch.curtis@nokia.com>
Tue, 21 Aug 2012 12:46:42 +0000 (14:46 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 5 Sep 2012 19:06:39 +0000 (21:06 +0200)
commit2b562b756401da02017ec937fd2716dd6b9863d3
tree3578f0a9ead68655887b7b2617ca1aa0695671fc
parentaba8de1bee8bbb9bc6b92e761a3dda0d829a211e
Fix 3 digit day being displayed by QDateEdit.

When a QDateEdit has its display format set to "yyyy/MM/dd", its day
set to 31 and its month set to 2, it will display 291 as the day until
the cursor is moved or the focus changed. This is because
QDateTimeParser::parse calls sectionSize() for the day section, which
will sometimes return an incorrect size. There are also other display
formats affected by this bug (e.g. long day names).

For example, (in the context of sectionSize()) when text is
"2000/01/31" and displayText() is "2000/2/31", there is a difference
between displayText() and text - text is the previous value and
displayText() is the new value. The size difference is always due to
leading zeroes.

This patch makes QDateTimeParser keep track of the quantity of zeroes
added to each section and then factors this value into the result of
sectionSize() if there is a size difference between text and
displayText().

Task-number: QTBUG-26847
Change-Id: I3823cc41167ec920f742cb6a20d39fc5f433c915
Reviewed-by: Mitch Curtis <mitch.curtis@nokia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Reviewed-by: aavit <qt_aavit@ovi.com>
src/corelib/tools/qdatetime.cpp
src/corelib/tools/qdatetime_p.h
tests/auto/widgets/widgets/qdatetimeedit/qdatetimeedit.pro
tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp