diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-09-26 16:54:53 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-11-30 20:19:29 +0000 |
commit | b4ef4469ba0a47eb5f2b395f9934a0d41139a85d (patch) | |
tree | cf13b80324b433a82963429c2a7c0cc298d53010 /src/corelib | |
parent | a755c2e52126bea850a04487a9a7d446b03e892a (diff) |
QDateTimeParser: reject all short values in fixed-width fields
Previously, a 1, 2 or 3 for "dd" would be rejected because 10, 20 or
30 would fit in the field and be valid; but 4 or more was accepted,
even though it was too short for the field, because no suffix could
make it valid within the field-width.
[ChangeLog][QtCore][QDateTime] When parsing dates and times from
strings, fixed-width date-time fields, such as a "dd" for day,
QDateTime now rejects all values that should be padded, rather
than only doing so when the value is a prefix of some value that
would fill the field-width. Use a single letter for the field,
e.g. "d" for day, if you want to accept short
values. (QDateTimeEdit is not affected.)
Task-number: QTBUG-63072
Change-Id: I22d223c50057c3edab4ef7f01d9ed0f58e9139c1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 15a2e58e1b..ff62eab4cc 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1145,7 +1145,8 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, } state = qMin<State>(state, sect.state); - if (state == Invalid || (state == Intermediate && context == FromString)) + // QDateTimeEdit can fix Intermediate and zeroes, but input needing that didn't match format: + if (state == Invalid || (context == FromString && (state == Intermediate || sect.zeroes))) return StateNode(); switch (sn.type) { |