aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-06-19 10:10:52 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-06-25 10:09:25 +0200
commit510253aa0996a89e6029d244002a08615b2fb65b (patch)
tree90f34289ffe658189c2caa495a4b744df9ef0593 /src/qml
parent5c672954e391d43e1fb94e6d76aaedc987dea468 (diff)
qv4dateobject.cpp: USE_QTZ_SYSTEM_TIMEZONE on more platforms
The only platform where we may have a semi-adequate native implementation of the time/date functions is windows. On all other platforms we should use QTimeZone::systemTimeZone() if possible as that at least gives us correct results when the system time zone doesn't change at runtime. Fixes: QTBUG-84474 Pick-to: 5.15 Change-Id: I34b01e12a751ee1c9b17735810e62e2e847f8446 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 310d393c12..e75d8bc740 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -54,11 +54,28 @@
#include <wtf/MathExtras.h>
-#if defined(Q_OS_LINUX) && QT_CONFIG(timezone) && !defined(Q_OS_ANDROID)
+#if QT_CONFIG(timezone) && !defined(Q_OS_WIN)
/*
See QTBUG-56899. Although we don't (yet) have a proper way to reset the
system zone, the code below, that uses QTimeZone::systemTimeZone(), works
- adequately on Linux, when the TZ environment variable is changed.
+ adequately on Linux.
+
+ QTimeZone::systemTimeZone() will automatically produce an updated value on
+ non-android Linux systems when the TZ environment variable or the relevant
+ files in /etc are changed. On other platforms it won't, and the information
+ produced here may be incorrect after changes to the system time zone.
+
+ We accept this defect for now because the localtime_r approach will
+ consistently produce incorrect results for some time zones, not only when
+ the system time zone changes. This is a worse problem, see also QTBUG-84474.
+
+ On windows we have a better implementation of getLocalTZA that hopefully
+ updates on time zone changes. However, we currently use the worse
+ implementation of DaylightSavingTA (returning either an hour or 0).
+
+ QTimeZone::systemTimeZone() on Linux is also slower than other approaches
+ because it has to poll the relevant files (if TZ is not set). See
+ QTBUG-75585 for an explanation and possible workarounds.
*/
#define USE_QTZ_SYSTEM_ZONE
#endif