Details
-
Task
-
Resolution: Done
-
P2: Important
-
5.15.0
-
None
-
13
-
dff02466a0 (qt/qtdeclarative/dev) 3033e99fa8 (qt/qtdeclarative/6.4) 3033e99fa8 (qt/tqtc-qtdeclarative/6.4)
Description
In the case that we don't use QTimeZone for the date/time calculations, DaylightSavingTA() looks like this:
// This implementation fails to take account of past changes in standard offset. static inline double DaylightSavingTA(double t, double /*localTZA*/) { struct tm tmtm; #if defined(Q_CC_MSVC) __time64_t tt = (__time64_t)(t / msPerSecond); // _localtime_64_s returns non-zero on failure if (_localtime64_s(&tmtm, &tt) != 0) #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) long int tt = (long int)(t / msPerSecond); if (!localtime_r((const time_t*) &tt, &tmtm)) #else // Returns shared static data which may be overwritten at any time // (for MinGW/Windows localtime is luckily thread safe) long int tt = (long int)(t / msPerSecond); if (struct tm *tmtm_p = localtime((const time_t*) &tt)) tmtm = *tmtm_p; else #endif return 0; return (tmtm.tm_isdst > 0) ? msPerHour : 0; }
This is obviously wrong because it can only return an hour or 0. There are non-zero daylight savings offsets different from one hour (two hours, minus an hour, at least). Also, as the initial comment points out, this code fails to take account of historical changes to the standard offset, which (despite its name) this function should be reporting (but can't).
With https://codereview.qt-project.org/c/qt/qtdeclarative/+/305018 we still use this implementation if !QT_CONFIG(timezone) and on windows. We need to reconsider what to do with it.
Attachments
Issue Links
- relates to
-
QTBUG-78996 JavaScript getDay() regression on MinGW
- Closed
-
QTBUG-95993 QML Date operations are wrong when DST is active
- Closed
-
QTBUG-100014 tst_qqmlqt fails on Android
- Closed