diff options
author | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-01-18 13:00:32 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@theqtcompany.com> | 2016-04-08 14:45:30 +0000 |
commit | ee22fe13cda74c5ef5ee7b6db1b75d2837e43672 (patch) | |
tree | 35ae4c036d38a1c7daa425fe5d8996a3251c268a /src/corelib | |
parent | b2c0e5af186201979f47a306e017eb8979248f00 (diff) |
QDateTimeParser::parse(): improve readability
A switch (was inconsistent about whether enum members need casts and)
made it less obvious, rather than more, what was going on; so changed
it to a nested if.
Change-Id: I9af322d9dd17aa08cac5003eff2c8eaa73b50d45
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 8e3eaf7074..cc09992b88 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -977,22 +977,17 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos if (state != Invalid) { if (parserType != QVariant::Time) { - if (year % 100 != year2digits) { - switch (isSet & (YearSection2Digits|YearSection)) { - case YearSection2Digits: + if (year % 100 != year2digits && (isSet & YearSection2Digits)) { + if (!(isSet & YearSection)) { year = (year / 100) * 100; year += year2digits; - break; - case ((uint)YearSection2Digits|(uint)YearSection): { + } else { conflicts = true; const SectionNode &sn = sectionNode(currentSectionIndex); if (sn.type == YearSection2Digits) { year = (year / 100) * 100; year += year2digits; } - break; } - default: - break; } } |