diff options
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 6 | ||||
-rw-r--r-- | tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 7085604197..9d60fcf65c 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -4551,9 +4551,9 @@ static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time); #if QT_CONFIG(timezone) - } else if (spec == Qt::TimeZone && d->m_timeZone.isValid()) { + } else if (spec == Qt::TimeZone && d.d->m_timeZone.isValid()) { QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), - d->m_timeZone, + d.d->m_timeZone, QDateTimePrivate::UnknownDaylightTime, date, time); #endif // timezone diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp index d3afee96cd..b60d67fd89 100644 --- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp @@ -1098,6 +1098,18 @@ void tst_QDateTime::addDays() QCOMPARE(dt2.timeSpec(), Qt::OffsetFromUTC); QCOMPARE(dt2.offsetFromUtc(), 60 * 60); +#if QT_CONFIG(timezone) + const QTimeZone cet("Europe/Oslo"); + if (cet.isValid()) { + dt1 = QDate(2022, 1, 10).startOfDay(cet); + dt2 = dt1.addDays(2); // QTBUG-99668: should not assert + QCOMPARE(dt2.date(), QDate(2022, 1, 12)); + QCOMPARE(dt2.time(), QTime(0, 0)); + QCOMPARE(dt2.timeSpec(), Qt::TimeZone); + QCOMPARE(dt2.timeZone(), cet); + } +#endif + // ### test invalid QDateTime() } |