summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Layt <jlayt@kde.org>2013-11-02 18:53:32 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-21 09:25:23 +0100
commit6ad97bfa736c97b50019d0192f55959848e7067a (patch)
treef0ce0c8a5808b19a1a08d8df934af0d927fca5d2 /src
parent8e6258f059140ce735391b6438d5976dc9469e95 (diff)
QTimeZone - Fix dateForLocalTime() to check validity of next transition
The private method dateForLocalTime() was not checking that transitions were valid, resulting in infinite looping when a time zone didn't have any future transitions. Change-Id: I0e5d07063861778dd86056a80c36fdd9f9d36133 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qtimezoneprivate.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp
index dd4e18e01f..08a5ce0861 100644
--- a/src/corelib/tools/qtimezoneprivate.cpp
+++ b/src/corelib/tools/qtimezoneprivate.cpp
@@ -264,7 +264,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs)
// If the local msecs is less than the real local time of the transition
// then get the previous transition to use instead
if (forLocalMSecs < tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000)) {
- while (forLocalMSecs < tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000)) {
+ while (tran.atMSecsSinceEpoch != invalidMSecs()
+ && forLocalMSecs < tran.atMSecsSinceEpoch + (tran.offsetFromUtc * 1000)) {
nextTran = tran;
tran = previousTransition(tran.atMSecsSinceEpoch);
}
@@ -272,7 +273,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs)
// The zone msecs is after the transition, so check it is before the next tran
// If not try use the next transition instead
nextTran = nextTransition(tran.atMSecsSinceEpoch);
- while (forLocalMSecs >= nextTran.atMSecsSinceEpoch + (nextTran.offsetFromUtc * 1000)) {
+ while (nextTran.atMSecsSinceEpoch != invalidMSecs()
+ && forLocalMSecs >= nextTran.atMSecsSinceEpoch + (nextTran.offsetFromUtc * 1000)) {
tran = nextTran;
nextTran = nextTransition(tran.atMSecsSinceEpoch);
}
@@ -292,7 +294,8 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs)
// then use the prev tran as we default to the FirstOccurrence
// TODO Check if faster to just always get prev tran, or if faster using 6 hour check.
Data dstTran = previousTransition(tran.atMSecsSinceEpoch);
- if (dstTran.daylightTimeOffset > 0 && diffPrevTran < (dstTran.daylightTimeOffset * 1000))
+ if (dstTran.atMSecsSinceEpoch != invalidMSecs()
+ && dstTran.daylightTimeOffset > 0 && diffPrevTran < (dstTran.daylightTimeOffset * 1000))
tran = dstTran;
} else if (diffNextTran >= 0 && diffNextTran <= (nextTran.daylightTimeOffset * 1000)) {
// If time falls within last hour of standard time then is actually the missing hour