From ced34cb3d5805f1fbaf3b275714a1a5f3585900c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 1 Oct 2018 20:01:54 +0200 Subject: QDateTimeParser: avoid using an invalid hour by default When a time-zone does a spring-forward, skipping an hour (either to start DST or to move its standard time), there's an hour that doesn't exist on the day in question. That hour can be the first hour of the day, in which case using 0:0 as the default time is broken. So catch this case and use the first time that day that makes sense. Fixes: QTBUG-70823 Change-Id: I23dae9320a3cdd2c988841a7db1b111edb945730 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index d460beafde..943805e228 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -2390,6 +2390,14 @@ void tst_QDateTime::fromStringStringFormat_data() QTest::newRow("data16") << QString("2005-06-28T07:57:30.001Z") << QString("yyyy-MM-ddThh:mm:ss.zt") << QDateTime(QDate(2005, 06, 28), QTime(07, 57, 30, 1), Qt::UTC); +#if QT_CONFIG(timezone) + QTimeZone southBrazil("America/Sao_Paulo"); + if (southBrazil.isValid()) { + QTest::newRow("spring-forward-midnight") + << QString("2008-10-19 23:45.678 America/Sao_Paulo") << QString("yyyy-MM-dd mm:ss.zzz t") + << QDateTime(QDate(2008, 10, 19), QTime(1, 23, 45, 678), southBrazil); + } +#endif QTest::newRow("late") << QString("9999-12-31T23:59:59.999Z") << QString("yyyy-MM-ddThh:mm:ss.zZ") << QDateTime(QDate(9999, 12, 31), QTime(23, 59, 59, 999)); -- cgit v1.2.3 From bc099f33ddc03af48fcef226a6c95e7dd79a64d4 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 4 Oct 2018 18:55:29 +0200 Subject: Support QCborMap::operator[] taking a string literal Use a template on the size of the char[], as suggested by Ville Voutilainen. This resolves ambiguity about whether such look-ups should be done via QString or QCborValue (not that it would have made any difference). When we come to add mutating indexing of QCborValue, chained dereferences like map[i][j][k] need to stay in operator[] const throughout, to avoid detaching intermediates to create references into them due to using the mutating operator[] on the earlier dereference's return. So const-qualify the QCborValue operator[] const variants at the same time, to match those of QCborValue itself. Change-Id: Ib1652ae9440fe3767a653afa2856b74040210e07 Reviewed-by: Thiago Macieira --- tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index b69c993efb..38b26e7de4 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -413,6 +413,9 @@ void tst_QCborValue::mapDefaultInitialization() QVERIFY(m.value(QLatin1String("Hello")).isUndefined()); QVERIFY(m.value(QStringLiteral("Hello")).isUndefined()); QVERIFY(m.value(QCborValue()).isUndefined()); +#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII) + QVERIFY(m.value("Hello").isUndefined()); +#endif QVERIFY(m == m); QVERIFY(m == QCborMap{}); -- cgit v1.2.3