Fix a typo, simplify an increment, add an assertion

Trivial details picked up during the course of investigating a
time-zone issue.

Change-Id: I4d6e7ab1787a2500bd950e7f12ed8618a31f1f8e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
bb10
Edward Welbourne 2021-02-16 15:36:40 +01:00
parent 1b34d68623
commit 76c2e9ea23
1 changed files with 5 additions and 3 deletions

View File

@ -3844,7 +3844,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const
case Qt::TimeZone:
Q_ASSERT(!d.isShort());
#if QT_CONFIG(timezone)
// Use offset refreshZonedDateTime() saved creation:
// Use offset refreshZonedDateTime() saved on creation:
if (d->m_timeZone.isValid())
return d->m_msecs - d->m_offsetFromUtc * 1000;
#endif
@ -3899,7 +3899,7 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
status |= QDateTimePrivate::ValidWhenMask;
break;
case Qt::OffsetFromUTC:
msecs = msecs + (d->m_offsetFromUtc * 1000);
msecs += d->m_offsetFromUtc * 1000;
status |= QDateTimePrivate::ValidWhenMask;
break;
case Qt::TimeZone:
@ -3947,8 +3947,10 @@ void QDateTime::setMSecsSinceEpoch(qint64 msecs)
d->m_msecs = msecs;
}
if (spec == Qt::LocalTime || spec == Qt::TimeZone)
if (spec == Qt::LocalTime || spec == Qt::TimeZone) {
refreshZonedDateTime(d, spec);
Q_ASSERT((d.isShort() ? d.data.msecs : d->m_msecs) == msecs);
}
}
/*!