summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-08-19 16:50:54 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 23:45:06 +0200
commit7b07c3ff781c9fcdaf7a60aabed9b7aa57e25006 (patch)
tree6bcf141cb1d0e97234746a131fc1335a38eb43f4 /tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
parent18322bfabc3c349040bb370167e2642dc734bd50 (diff)
QDateTime - Fix Daylight Transition for "missing" hour
When Daylight Time transtion goes from Standard Time to Daylight Time there is a "missing" hour, i.e. at 2am CET the clock goes forward to 3am. Currently QDateTime ignores this gap and considers the time to be valid and able to be manipulated. This change respects the transition, so any time set in the missing hour is considered invalid, and any date maths returns valid results. The validity in the current time zone needs to be checked every time isValid() is called in case the system time zone has changed since the last time it was checked. This is done by calling mktime to check the returned result matches the expected result. This could be very inefficient, but the returned offset value is cached each time so mktime is not required to be called again within each method call, effectively meaning mktime is called the same number of times by each method. Note that this means any new methods added must be careful to ensure either isValid() or refreshLocalTime() is called first by any method needing to use the UTC value. [ChangeLog][QtCore][QDateTime] The Standard Time to Daylight Time transition for Qt::LocalTime is now handled correctly. Any date set in the "missing" hour is now considered invalid. All date math results that fall into the missing hour will be automatically adjusted to a valid time in the following hour. Change-Id: Ia652c8511b45df15f4917acf12403ec01a7f08e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp')
-rw-r--r--tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp6
1 files changed, 0 insertions, 6 deletions
diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
index 710da0dc1e..2ba0a1a57b 100644
--- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
@@ -1024,7 +1024,6 @@ void tst_QDateTime::addSecs()
QFETCH(QDateTime, dt);
QFETCH(int, nsecs);
QFETCH(QDateTime, result);
-
#ifdef Q_OS_IRIX
QEXPECT_FAIL("cet4", "IRIX databases say 1970 had DST", Abort);
#endif
@@ -2342,7 +2341,6 @@ void tst_QDateTime::daylightTransitions() const
QCOMPARE(before.toMSecsSinceEpoch(), daylight2012 - 1);
QDateTime missing(QDate(2012, 3, 25), QTime(2, 0, 0));
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QVERIFY(!missing.isValid());
QCOMPARE(missing.date(), QDate(2012, 3, 25));
QCOMPARE(missing.time(), QTime(2, 0, 0));
@@ -2374,7 +2372,6 @@ void tst_QDateTime::daylightTransitions() const
QCOMPARE(utc.date(), QDate(2012, 3, 25));
QCOMPARE(utc.time(), QTime(2, 0, 0));
utc.setTimeSpec(Qt::LocalTime);
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QVERIFY(!utc.isValid());
QCOMPARE(utc.date(), QDate(2012, 3, 25));
QCOMPARE(utc.time(), QTime(2, 0, 0));
@@ -2390,7 +2387,6 @@ void tst_QDateTime::daylightTransitions() const
test = test.addYears(1);
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 3, 25));
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(test.time(), QTime(3, 0, 0));
test = QDateTime(QDate(2012, 2, 25), QTime(2, 0, 0));
@@ -2398,7 +2394,6 @@ void tst_QDateTime::daylightTransitions() const
test = test.addMonths(1);
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 3, 25));
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(test.time(), QTime(3, 0, 0));
test = QDateTime(QDate(2012, 3, 24), QTime(2, 0, 0));
@@ -2406,7 +2401,6 @@ void tst_QDateTime::daylightTransitions() const
test = test.addDays(1);
QVERIFY(test.isValid());
QCOMPARE(test.date(), QDate(2012, 3, 25));
- QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue);
QCOMPARE(test.time(), QTime(3, 0, 0));
test = QDateTime(QDate(2012, 3, 25), QTime(1, 0, 0));