From 3f44e0fc5f1d55498ce7fb93a7841198a7583a08 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 24 Sep 2019 12:24:16 +0200 Subject: Convert QTime to V4 Date on a date with no DST in force Sadly the third centennary of Cassini's birth isn't such a good date after all, since round-tripping will ignore DST on the QDateTime leg but include it in V4's implementation of ES's ill-conceived spec for handling DST and time-zone transitions; and June 8th is in summer for much of the world. So use a date which (as far as I can tell) appears to have been DST-free everywhere; and after the start of 1970 so that, even if we find ourselves working with a zone in which it did have DST, we'll apply DST consistently during round-tripping. Fixes: QTBUG-78706 Change-Id: I25be2548e2c97eae2c4f6c5bbe661dea2f35aaba Reviewed-by: Ulf Hermann --- src/qml/jsruntime/qv4dateobject.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/qml/jsruntime/qv4dateobject.cpp') diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index bba88e5c9a..5616b1450b 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -729,14 +729,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)); } -- cgit v1.2.3