summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2013-03-06 10:00:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-12 11:43:01 +0100
commit6bc691dde53a3056d708d94d8bb1317d622835b0 (patch)
treef7371446f88bda791aa2d274c24753f12763a338
parent124da59cb40df5e47e7183dfef90bcd5957ed71f (diff)
Revert 6497649730daeab5d3dfac7e806105e99a237656 and clarify docs.
It introduced a regression by requiring that a p/P was also present: QTime time = QTime::currentTime(); qDebug() << time.toString("h:mm:ss a"); // Outputs "10:05:42 am" in Qt 4.8. // Outputs "10:05:42 a" with 6497649730daeab5d3dfac7e806105e99a237656. This patch also clarifies the QTime::toString(QString) documentation. Change-Id: I4d73a959c2ca76304f03a4ce9717b540ad4e8811 Reviewed-by: Andy Shaw <andy.shaw@digia.com>
-rw-r--r--src/corelib/tools/qdatetime.cpp7
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp6
2 files changed, 3 insertions, 10 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 4b6e739759..bf3cc68c06 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -1560,9 +1560,9 @@ QString QTime::toString(Qt::DateFormat format) const
\row \li z \li the milliseconds without leading zeroes (0 to 999)
\row \li zzz \li the milliseconds with leading zeroes (000 to 999)
\row \li AP or A
- \li use AM/PM display. \e AP will be replaced by either "AM" or "PM".
+ \li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM".
\row \li ap or a
- \li use am/pm display. \e ap will be replaced by either "am" or "pm".
+ \li use am/pm display. \e a/ap will be replaced by either "am" or "pm".
\row \li t \li the timezone (for example "CEST")
\endtable
@@ -3759,8 +3759,7 @@ static bool hasUnquotedAP(const QString &f)
for (int i=0; i<max; ++i) {
if (f.at(i) == quote) {
inquote = !inquote;
- } else if (!inquote && f.at(i).toUpper() == QLatin1Char('A')
- && i + 1 < max && f.at(i + 1).toUpper() == QLatin1Char('P')) {
+ } else if (!inquote && f.at(i).toUpper() == QLatin1Char('A')) {
return true;
}
}
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 05a6c6b252..b1874131d7 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -1437,16 +1437,10 @@ void tst_QDateTime::toString_strformat_data()
QTest::newRow( "datetime13" ) << QDateTime(QDate(1974, 12, 1), QTime(14, 14, 20))
<< QString("hh''mm''ss dd''MM''yyyy")
<< QString("14'14'20 01'12'1974");
- QTest::newRow( "missing p and P" ) << QDateTime(QDate(1999, 12, 31), QTime(3, 59, 59, 999))
- << QString("hhhhhaA") << QString("03033aA");
- QTest::newRow( "OK A, bad P" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))
- << QString("hhAX") << QString("00AX");
QTest::newRow( "single, 0 => 12 AM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))
<< QString("hAP") << QString("12AM");
QTest::newRow( "double, 0 => 12 AM" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))
<< QString("hhAP") << QString("12AM");
- QTest::newRow( "double, garbage" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))
- << QString("hhAX") << QString("00AX");
QTest::newRow( "dddd" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))
<< QString("dddd") << QString("Friday");
QTest::newRow( "ddd" ) << QDateTime(QDate(1999, 12, 31), QTime(0, 59, 59, 999))