diff options
author | Liang Qi <liang.qi@qt.io> | 2019-06-27 14:38:03 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-06-27 14:38:03 +0200 |
commit | 25eb97d2d450fbfe761559f1ae87a2e88c8c6b2d (patch) | |
tree | a96380908abb944ff374201321fa5a50d15b770a /src/corelib/time/qdatetimeparser.cpp | |
parent | fc940b24dbe8a118e92e335c0d9c7d4194bf3d4f (diff) | |
parent | 0d6b4b519272915c2690ee12d1834823747233ab (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
.qmake.conf
src/network/ssl/qsslsocket_openssl.cpp
Done-With: Timur Pocheptsov <timur.pocheptsov@qt.io>
Change-Id: Ibb57a0548b4977797b400637487a56245ac1c024
Diffstat (limited to 'src/corelib/time/qdatetimeparser.cpp')
-rw-r--r-- | src/corelib/time/qdatetimeparser.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 728b066db1..fc369bae75 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -621,11 +621,11 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const case LastSection: return 0; case AmPmSection: { - const int lowerMax = qMin(getAmPmText(AmText, LowerCase).size(), + const int lowerMax = qMax(getAmPmText(AmText, LowerCase).size(), getAmPmText(PmText, LowerCase).size()); - const int upperMax = qMin(getAmPmText(AmText, UpperCase).size(), + const int upperMax = qMax(getAmPmText(AmText, UpperCase).size(), getAmPmText(PmText, UpperCase).size()); - return qMin(4, qMin(lowerMax, upperMax)); + return qMax(lowerMax, upperMax); } case Hour24Section: @@ -1664,13 +1664,16 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, /*! \internal - Returns - AM if str == tr("AM") - PM if str == tr("PM") - PossibleAM if str can become tr("AM") - PossiblePM if str can become tr("PM") - PossibleBoth if str can become tr("PM") and can become tr("AM") - Neither if str can't become anything sensible + Compares str to the am/pm texts returned by getAmPmText(). + Returns AM or PM if str is one of those texts. Failing that, it looks to see + whether, ignoring spaces and case, each character of str appears in one of + the am/pm texts. + If neither text can be the result of the user typing more into str, returns + Neither. If both texts are possible results of further typing, returns + PossibleBoth. Otherwise, only one of them is a possible completion, so this + returns PossibleAM or PossiblePM to indicate which. + + \sa getAmPmText() */ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionIndex, int *used) const { @@ -1699,10 +1702,10 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI QDTPDEBUG << "findAmPm" << str << ampm[0] << ampm[1]; - if (str.indexOf(ampm[amindex], 0, Qt::CaseInsensitive) == 0) { + if (str.startsWith(ampm[amindex], Qt::CaseInsensitive)) { str = ampm[amindex]; return AM; - } else if (str.indexOf(ampm[pmindex], 0, Qt::CaseInsensitive) == 0) { + } else if (str.startsWith(ampm[pmindex], Qt::CaseInsensitive)) { str = ampm[pmindex]; return PM; } else if (context == FromString || (str.count(space) == 0 && str.size() >= size)) { |