aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4dateobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4dateobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index e313ebe300..cc89947cec 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -52,11 +52,9 @@
#include <time.h>
-#include <private/qqmljsengine_p.h>
-
#include <wtf/MathExtras.h>
-#if defined(Q_OS_LINUX) && QT_CONFIG(timezone)
+#if defined(Q_OS_LINUX) && QT_CONFIG(timezone) && !defined(Q_OS_ANDROID)
/*
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
@@ -618,8 +616,7 @@ static inline double ParseString(const QString &s, double localTZA)
QStringLiteral("d MMMM, yyyy hh:mm:ss"),
};
- for (uint i = 0; i < sizeof(formats) / sizeof(formats[0]); ++i) {
- const QString &format(formats[i]);
+ for (const QString &format : formats) {
dt = format.indexOf(QLatin1String("hh:mm")) < 0
? QDateTime(QDate::fromString(s, format),
QTime(0, 0, 0), Qt::UTC)
@@ -746,14 +743,16 @@ void Heap::DateObject::init(const QTime &time)
* time from it, which shall (via toQDateTime(), below) discard the date
* part. We need a date for which time-zone data is likely to be sane (so
* MakeDay(0, 0, 0) was a bad choice; 2 BC, December 31st is before
- * time-zones were standardized), with no transition nearby in date. We
- * ignore DST transitions before 1970, but even then zone transitions did
- * happen. Some do happen at new year, others on DST transitions in spring
- * and autumn; so pick the three hundredth anniversary of the birth of
- * Giovanni Domenico Cassini (1625-06-08), whose work first let us
- * synchronize clocks tolerably accurately at distant locations.
+ * time-zones were standardized), with no transition nearby in date.
+ * QDateTime ignores DST transitions before 1970, but even then zone
+ * transitions did happen; and DaylightSavingTA() will include DST, at odds
+ * with QDateTime. So pick a date since 1970 and prefer one when no zone
+ * was in DST. One such interval (according to the Olson database, at
+ * least) was 1971 March 15th to April 17th. Since converting a time to a
+ * date-time without specifying a date is foolish, let's use April Fools'
+ * day.
*/
- static const double d = MakeDay(1925, 5, 8);
+ static const double d = MakeDay(1971, 3, 1);
double t = MakeTime(time.hour(), time.minute(), time.second(), time.msec());
date = TimeClip(UTC(MakeDate(d, t), internalClass->engine->localTZA));
}