Fix QIcuTimeZonePrivate::hasDaylightTime() to catch historical DST
QTimeZone::hasDaylightTime() is documented to return true if a zone has ever dabbled in DST, but the ICU implementation was only detecting whether the zone currently engages in it. When the transitions API is available (currently for version == 50; will soon change to >= 50), use it to find out whether DST was ever in effect. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I4576de2e074dc57b54450b1e40a23358ccf0ef49 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
845eabb314
commit
d9602efe88
@ -386,8 +386,17 @@ int QIcuTimeZonePrivate::daylightTimeOffset(qint64 atMSecsSinceEpoch) const
|
||||
|
||||
bool QIcuTimeZonePrivate::hasDaylightTime() const
|
||||
{
|
||||
// TODO No direct ICU C api, work-around below not reliable? Find a better way?
|
||||
return (ucalDaylightOffset(m_id) != 0);
|
||||
if (ucalDaylightOffset(m_id) != 0)
|
||||
return true;
|
||||
#if U_ICU_VERSION_MAJOR_NUM == 50
|
||||
for (qint64 when = minMSecs(); when != invalidMSecs(); ) {
|
||||
auto data = nextTransition(when);
|
||||
if (data.daylightTimeOffset && data.daylightTimeOffset != invalidSeconds())
|
||||
return true;
|
||||
when = data.atMSecsSinceEpoch;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QIcuTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const
|
||||
|
Loading…
x
Reference in New Issue
Block a user