Merge integration refs/builds/qtci/dev/1618561273

This commit is contained in:
Qt CI Bot 2021-04-16 14:49:26 +00:00
commit 07d4a981a2
3 changed files with 21 additions and 12 deletions

View File

@ -607,9 +607,11 @@ QString QTimeZone::abbreviation(const QDateTime &atDateTime) const
int QTimeZone::offsetFromUtc(const QDateTime &atDateTime) const
{
if (isValid())
return d->offsetFromUtc(atDateTime.toMSecsSinceEpoch());
if (isValid()) {
const int offset = d->offsetFromUtc(atDateTime.toMSecsSinceEpoch());
if (offset != QTimeZonePrivate::invalidSeconds())
return offset;
}
return 0;
}
@ -627,9 +629,11 @@ int QTimeZone::offsetFromUtc(const QDateTime &atDateTime) const
int QTimeZone::standardTimeOffset(const QDateTime &atDateTime) const
{
if (isValid())
return d->standardTimeOffset(atDateTime.toMSecsSinceEpoch());
if (isValid()) {
const int offset = d->standardTimeOffset(atDateTime.toMSecsSinceEpoch());
if (offset != QTimeZonePrivate::invalidSeconds())
return offset;
}
return 0;
}
@ -647,9 +651,11 @@ int QTimeZone::standardTimeOffset(const QDateTime &atDateTime) const
int QTimeZone::daylightTimeOffset(const QDateTime &atDateTime) const
{
if (hasDaylightTime())
return d->daylightTimeOffset(atDateTime.toMSecsSinceEpoch());
if (hasDaylightTime()) {
const int offset = d->daylightTimeOffset(atDateTime.toMSecsSinceEpoch());
if (offset != QTimeZonePrivate::invalidSeconds())
return offset;
}
return 0;
}

View File

@ -224,7 +224,10 @@ QString QTimeZonePrivate::abbreviation(qint64 atMSecsSinceEpoch) const
int QTimeZonePrivate::offsetFromUtc(qint64 atMSecsSinceEpoch) const
{
return standardTimeOffset(atMSecsSinceEpoch) + daylightTimeOffset(atMSecsSinceEpoch);
const int std = standardTimeOffset(atMSecsSinceEpoch);
const int dst = daylightTimeOffset(atMSecsSinceEpoch);
const int bad = invalidSeconds();
return std == bad || dst == bad ? bad : std + dst;
}
int QTimeZonePrivate::standardTimeOffset(qint64 atMSecsSinceEpoch) const

View File

@ -996,10 +996,10 @@ void tst_QTimeZone::malformed()
const QDateTime now = QDateTime::currentDateTime();
QTimeZone barf("QUT4tCZ0 , /");
if (barf.isValid())
barf.offsetFromUtc(now);
QCOMPARE(barf.offsetFromUtc(now), 0);
barf = QTimeZone("QtC+09,,MA");
if (barf.isValid())
barf.offsetFromUtc(now);
QCOMPARE(barf.offsetFromUtc(now), 0);
}
void tst_QTimeZone::utcTest()