diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-02-11 11:29:19 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-02-24 12:08:57 +0100 |
commit | e8c52d0e8ce617c49bcd76ca542eaa024d2f1d08 (patch) | |
tree | 3cabed0b6debc1550f005f7c80c35f47a31deff1 /src/corelib/time/qtimezoneprivate.cpp | |
parent | 88d830929015e085a5532948170bebcdede98bb8 (diff) |
Fix transitionEachZone() failures on Android
In QTimeZonePrivate::dataForLocalTime(), mistrust the Android
backend's hasDaylightTime(), as it has a comment saying it only knows
about future transitions, not past. This caller of it really needs to
query "has ever had a transition", which this doesn't answer. Many
zones that have no plans for future transitions have had transitions
in the past; these were failing the transitionEachZone() test.
In the process, refine the test itself, making sure we catch some
quirk cases that shouldn't arise and making the debug message on
failure more informative (while eliding the zone name, as this is part
of the test name anyway, so added to the output by qDebug() itself).
Fixes: QTBUG-69131
Change-Id: I88a0528182c247acb8b6327b40516178e455bcc0
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/time/qtimezoneprivate.cpp')
-rw-r--r-- | src/corelib/time/qtimezoneprivate.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index ad35daa6f6..8b37c78241 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -258,8 +258,13 @@ QTimeZonePrivate::Data QTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const // Private only method for use by QDateTime to convert local msecs to epoch msecs QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, int hint) const { +#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_EMBEDDED) + // The Android back-end's hasDaylightTime() is only true for zones with + // transitions in the future; we need it to mean "has ever had a transition" + // though, so can't trust it here. if (!hasDaylightTime()) // No DST means same offset for all local msecs return data(forLocalMSecs - standardTimeOffset(forLocalMSecs) * 1000); +#endif /* We need a UTC time at which to ask for the offset, in order to be able to |