diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-23 14:56:17 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-25 17:04:37 +0100 |
commit | d9602efe8873083c7eb5171dc26b2ecdfa071841 (patch) | |
tree | abf58ba531e6f6a12654c1ddf2a3e2639cd967a8 /src | |
parent | 845eabb3145982320dce205ebd5bb034e66dfbc8 (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/time/qtimezoneprivate_icu.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp index b1de236fcb..1f07057168 100644 --- a/src/corelib/time/qtimezoneprivate_icu.cpp +++ b/src/corelib/time/qtimezoneprivate_icu.cpp @@ -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 |