diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-07 01:00:08 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2018-10-08 10:00:49 +0200 |
commit | b4da5c6b931fb726fade891448f01c266cb3c115 (patch) | |
tree | 2f9289340da1470cf317f6670f309968da7f18e8 /src/corelib | |
parent | 05b8ba51550127c85cd2db5cb819b695b56c57ce (diff) | |
parent | 7146c9075c85cb46cb38b57ded3e12dfa6cbef66 (diff) |
Merge remote-tracking branch 'origin/5.11' into 5.12
Conflicts:
src/corelib/tools/qtimezoneprivate.cpp
Change-Id: Icbb5999d378711ce3786a4fe0aba176a45ac702c
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 29 | ||||
-rw-r--r-- | src/corelib/tools/qtimezoneprivate.cpp | 2 |
2 files changed, 26 insertions, 5 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 18c44c3a17..e6afd510fd 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -1341,12 +1341,33 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, const QDate date(year, month, day); const QTime time(hour, minute, second, msec); - return StateNode( + const QDateTime when = #if QT_CONFIG(timezone) - tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : + tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : #endif - QDateTime(date, time, tspec, zoneOffset), - state, padding, conflicts); + QDateTime(date, time, tspec, zoneOffset); + + // If hour wasn't specified, check the default we're using exists on the + // given date (which might be a spring-forward, skipping an hour). + if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) { + qint64 msecs = when.toMSecsSinceEpoch(); + // Fortunately, that gets a useful answer ... + const QDateTime replace = +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone + ? QDateTime::fromMSecsSinceEpoch(msecs, timeZone) : +#endif + QDateTime::fromMSecsSinceEpoch(msecs, tspec, zoneOffset); + const QTime tick = replace.time(); + if (replace.date() == date + && (!(isSet & MinuteSection) || tick.minute() == minute) + && (!(isSet & SecondSection) || tick.second() == second) + && (!(isSet & MSecSection) || tick.msec() == msec)) { + return StateNode(replace, state, padding, conflicts); + } + } + + return StateNode(when, state, padding, conflicts); } /*! diff --git a/src/corelib/tools/qtimezoneprivate.cpp b/src/corelib/tools/qtimezoneprivate.cpp index 8bf7336a42..569b343187 100644 --- a/src/corelib/tools/qtimezoneprivate.cpp +++ b/src/corelib/tools/qtimezoneprivate.cpp @@ -440,7 +440,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, utcEpochMSecs = forStd; } else { // Invalid forLocalMSecs: in spring-forward gap. - const int dstStep = daylightTimeOffset(early < late ? imminent : recent); + const int dstStep = daylightTimeOffset(early < late ? imminent : recent) * 1000; Q_ASSERT(dstStep); // There can't be a transition without it ! utcEpochMSecs = (hint > 0) ? forStd - dstStep : forDst + dstStep; } |