diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-23 15:32:05 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-03-25 17:04:38 +0100 |
commit | eda8b7b4dad6fada6c7afa43b7df0f531d2504d1 (patch) | |
tree | 9b65526143bac7fa0e64c671f3e77457338b096c /src | |
parent | 934b5287152006807178b93119aa166f0751df87 (diff) |
Enable QIcuTimeZonePrivate's support for transitions
The support was previously limited to ICU version 50, with an == check
rather than a >= one, accompanied by a TODO comment to check whether
the API was stable at 51. Nine years have passed since ICU 51 was
released, we're now up to release 70, and now I've finally verified
that the API is stable (and fixed a few bugs in how we use it). So
change the check so that we now do use the transition API.
Fixes: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: Ica024b6c28a213e0de0a37f196839e8ded193889
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/time/qtimezoneprivate_icu.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/corelib/time/qtimezoneprivate_icu.cpp b/src/corelib/time/qtimezoneprivate_icu.cpp index f343e0fec2..4cfcd6523c 100644 --- a/src/corelib/time/qtimezoneprivate_icu.cpp +++ b/src/corelib/time/qtimezoneprivate_icu.cpp @@ -183,8 +183,7 @@ static bool ucalOffsetsAtTime(UCalendar *m_ucal, qint64 atMSecsSinceEpoch, return false; } -// ICU Draft api in v50, should be stable in ICU v51. Available in C++ api from ICU v3.8 -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 // Qt wrapper around qt_ucal_getTimeZoneTransitionDate & ucal_get static QTimeZonePrivate::Data ucalTimeZoneTransition(UCalendar *m_ucal, UTimeZoneTransitionType type, @@ -388,7 +387,7 @@ bool QIcuTimeZonePrivate::hasDaylightTime() const { if (ucalDaylightOffset(m_id) != 0) return true; -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 for (qint64 when = minMSecs(); when != invalidMSecs(); ) { auto data = nextTransition(when); if (data.daylightTimeOffset && data.daylightTimeOffset != invalidSeconds()) @@ -424,13 +423,12 @@ bool QIcuTimeZonePrivate::isDaylightTime(qint64 atMSecsSinceEpoch) const QTimeZonePrivate::Data QIcuTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const { // Available in ICU C++ api, and draft C api in v50 - // TODO When v51 released see if api is stable QTimeZonePrivate::Data data = invalidData(); -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 data = ucalTimeZoneTransition(m_ucal, UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE, forMSecsSinceEpoch); if (data.atMSecsSinceEpoch == invalidMSecs()) // before first transition -#endif // U_ICU_VERSION_MAJOR_NUM >= 50 +#endif { ucalOffsetsAtTime(m_ucal, forMSecsSinceEpoch, &data.standardTimeOffset, &data.daylightTimeOffset); @@ -444,36 +442,33 @@ QTimeZonePrivate::Data QIcuTimeZonePrivate::data(qint64 forMSecsSinceEpoch) cons bool QIcuTimeZonePrivate::hasTransitions() const { // Available in ICU C++ api, and draft C api in v50 - // TODO When v51 released see if api is stable -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 return true; #else return false; -#endif // U_ICU_VERSION_MAJOR_NUM == 50 +#endif } QTimeZonePrivate::Data QIcuTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const { // Available in ICU C++ api, and draft C api in v50 - // TODO When v51 released see if api is stable -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 return ucalTimeZoneTransition(m_ucal, UCAL_TZ_TRANSITION_NEXT, afterMSecsSinceEpoch); #else Q_UNUSED(afterMSecsSinceEpoch); return invalidData(); -#endif // U_ICU_VERSION_MAJOR_NUM == 50 +#endif } QTimeZonePrivate::Data QIcuTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const { // Available in ICU C++ api, and draft C api in v50 - // TODO When v51 released see if api is stable -#if U_ICU_VERSION_MAJOR_NUM == 50 +#if U_ICU_VERSION_MAJOR_NUM >= 50 return ucalTimeZoneTransition(m_ucal, UCAL_TZ_TRANSITION_PREVIOUS, beforeMSecsSinceEpoch); #else Q_UNUSED(beforeMSecsSinceEpoch); return invalidData(); -#endif // U_ICU_VERSION_MAJOR_NUM == 50 +#endif } QByteArray QIcuTimeZonePrivate::systemTimeZoneId() const |