summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qdatetime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-111-10/+13
|\ | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qobject.cpp src/gui/painting/qpaintengine_raster.cpp Change-Id: I74e1779832f43d033708dcfd6b666c7b4f0111fb
| * QDateTime: don't allocate memory in fromOffsetString()Anton Kudryavtsev2016-04-091-9/+12
| | | | | | | | | | | | | | | | Manual splitting instead of QStringRef::split() Change-Id: I27ccf1c4e44ead5b13f85f2cdbd990cb3b874a7a Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
| * QDateTime: add some constAnton Kudryavtsev2016-04-091-1/+1
| | | | | | | | | | | | | | | | For CoW types const methods will be called. For QDate we can use new const getDate() method. Change-Id: Ie3a4fe48b3635d270a79c9ac5205b835b3442eae Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-051-0/+2
|\| | | | | | | | | | | | | | | | | Conflicts: examples/corelib/ipc/ipc.pro src/plugins/platforms/xcb/qxcbbackingstore.cpp tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp Change-Id: Ia006e10ff1732fe78f90138c41f05b59b49486cf
| * Do not use timezone at all for Q_OS_INTEGRITY.Rolland Dudemaine2016-03-221-0/+2
| | | | | | | | | | Change-Id: I3674b86b65a6ec47c89cc4f49e00361e9b87a7c3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QtCore: Remove Windows CE.Friedemann Kleint2016-03-301-101/+4
|/ | | | | | | | | Remove QSysInfo::WV_CE_5/6 enumeration values, #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library, examples and tests. Task-number: QTBUG-51673 Change-Id: Ib63463445f3a26e04d018b193e4655030002f5f9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QDate: mark getDate() as const.Anton Kudryavtsev2016-02-171-1/+14
| | | | | | | | | | This method does not modify the object. Can't change the API, so overload and mark the old function for removal in Qt 6. Change-Id: I4aee2bc19209646adc21388375aedd20a09129d0 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Revert "Correct floordiv() to cope with implementation-defined division."Edward Welbourne2016-01-291-10/+6
| | | | | | | | | | | This reverts commit cd9625fc3cacb4efd0da57d9f5780671f5c1310f. The ambiguity in division, with negative operands, goes away in C++11 (where division is defined to truncate, hence round towards zero), so we no longer need to be robust against it in 5.7. Added suitable commentary to make clear that we are relying on that. Change-Id: Id2c0d421bad4bcec87de9cc9519cd00df2456930 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-261-9/+13
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java src/dbus/qdbusconnection_p.h src/dbus/qdbusintegrator.cpp src/dbus/qdbusintegrator_p.h tests/auto/corelib/io/qdir/qdir.pro tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp Change-Id: I3d3fd07aed015c74b1f545f1327aa73d5f365fcc
| * Fix some mis-guided fall-throughs #ifdef QT_BOOTSTRAPPED.Edward Welbourne2016-01-211-9/+13
| | | | | | | | | | | | | | | | | | | | A switch had a case whose body was in a #ifndef; when that got elided, this case fell through into an entirely misguided case. Give the #if a #else clause so that it break;s in the defined case. Code review revealed another, then I searched for more following the same pattern. Change-Id: I57fb59b6c8d349604f3fc6c8b1d424fb3c775d50 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge "Merge remote-tracking branch 'origin/5.6' into dev" into refs/staging/devLiang Qi2016-01-261-32/+51
|\ \
| * | Merge remote-tracking branch 'origin/5.6' into devLiang Qi2016-01-211-32/+51
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice_p.h src/corelib/kernel/qvariant_p.h src/corelib/tools/qsimd.cpp src/gui/kernel/qguiapplication.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp Change-Id: I742a093cbb231b282b43e463ec67173e0d29f57a
| | * Correct floordiv() to cope with implementation-defined division.Edward Welbourne2016-01-131-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Irrelevant once we get to C++11 (so we can revert this in 5.7), but division's rounding direction is implementation defined when either operand is negative [0]. The prior code assumed C++11's truncation (a.k.a. round towards zero), but rounding may be downwards instead. [0] http://en.cppreference.com/w/cpp/language/operator_arithmetic#Multiplicative_operators Change-Id: I2b6b27e1cf629def48b25433e81b9ed8230d8795 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| | * Don't pretend we know what DST to use for an offset date.Edward Welbourne2016-01-121-30/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QDateTime::addDate() and friends sanitize their end-state, they were using the DST status of their start-state (if known) to control it. This lead to misguided results and, in particular, inconsistent results given that a raw-constructed QDateTime comes into being ignorant of its DST, while a .toLocalTime() one knows its DST. Furthermore, the code to do this was triplicated, tricky and poorly explained. So pull it out into a local static function and explain what it's doing, and why, more clearly and only once. Task-number: QTBUG-49008 Change-Id: Ia4bb3c5e9267fff8bb963ea705267998218ed623 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* | | Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
|/ / | | | | | | | | | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into devSimon Hausmann2016-01-121-1/+1
|\| | | | | | | Change-Id: I5839bded07e23af65ced9491c4f50242f964dd31
| * QDate: fix calculation of the week number for the last days of 2020Thiago Macieira2016-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | Off-by-one error: we should have calculated whether the current year is leap, not the next year. This affected any 53-week leap years. Task-number: QTBUG-50273 Change-Id: I134ce5db2f82468585ffffff14264cb9f12998fd Reviewed-by: Martin Klapetek <mklapetek@kde.org> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Don't allocate memory when creating an invalid QDateTimeSérgio Martins2015-12-101-1/+3
|/ | | | | | Task-Id: QTBUG-47779 Change-Id: I5aad835c9fbf50962d64d14519ec31cf38cf9e3b Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Prefer "daylight-saving time" and "DST" over "daylight time".Edward Welbourne2015-11-121-34/+34
| | | | | | | | | | | The first two are the "proper" terms; the last is a colloquialism. Also amended "daylight savings" (which summons to mind a hybrid of "daylight robbery" and "bargain-basket savings"). Improved related wording in many of the places amended. Task-number: QTBUG-49308 Change-Id: I726f18a344b2fe37f765a14684d1447c8b7ab00c Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Fix false claim in comment.Edward Welbourne2015-11-061-1/+1
| | | | | | | | | | Given that % and / have a defined consistency relation, neither is any better defined for -ve operands than the other. The code is in fact avoiding using -ve operands, not preferring "well-defined" / over (allegedly less so) %, as it claimed. Change-Id: I666690872f078c0f21f9af7a227c2bbf291704e8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make variable const as it should beEdward Welbourne2015-11-041-1/+1
| | | | | Change-Id: If5782473eceaa38de75b25d1da247dea9fe135da Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Use memset to clear struct tm before filling fields.Edward Welbourne2015-11-041-2/+2
| | | | | | | | This ensures any non-standard fields (e.g. glibc's tm_gmtoff) are clear, as well as the other fields mktime overtly promises to ignore. Change-Id: I45d69eff7b5cb37ab910bf3d4d2d1481fd93aedb Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-10-021-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/tools/qstring.h src/gui/image/qimagereader.cpp src/network/access/qnetworkaccessmanager.cpp src/tools/qdoc/doc/examples/examples.qdoc src/widgets/accessible/qaccessiblewidgetfactory_p.h src/widgets/doc/qtwidgets.qdocconf Change-Id: I8fae62283aebefe24e5ca4b4abd97386560c0fcb
| * QDateTime: Ensure a valid timezone when using the "offset constructor".Christian Kandeler2015-09-231-0/+1
| | | | | | | | | | | | | | | | The timeZone() function used to assert when called on such an object (or, for a release build, return an invalid time zone). Change-Id: I6ae8316b2ad76f1f868e2498f7ce8aa3fcabf4a6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDateTime: Remove redundant check.Christian Kandeler2015-09-231-15/+13
|/ | | | | Change-Id: I1a027526f24707f9431fe60ad08e41b5b07ffea3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid overflow in QTime::addSecs with too big a number of secondsThiago Macieira2015-08-191-0/+1
| | | | | | | | | | QDateTime::addSecs needs to do something similar, but not identical because it needs the number of days too. And then there are daylight savings transitions... Task-number: QTBUG-47717 Change-Id: I7de033f80b0e4431b7f1ffff13f976f4f5e5a059 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* Remove unnecessary QDateTime::detach() functionThiago Macieira2015-04-071-21/+4
| | | | | | | | | | | | | | | Last commit changed QDateTime::d to be a QSharedDataPointer that implicitly detaches on non-const operator->() calls. That means we no longer need to explicitly call detach(). More than that, we should not do it, so we avoid checking the ref count and try to detach on every use. To do that, in functions where the d pointer was accessed more than once, I detach at the top and shadow the "d" variable with a local plain pointer. We don't compile our sources with -Wshadow, so this should not be a problem. Change-Id: Ic5d393bfd36e48a193fcffff13b969c281c36d0c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QDateTime: remove unused parameter from localMSecsToEpochMSecs()Marc Mutz2015-03-261-10/+4
| | | | | | | | ...a namespace-level static function. The ok parameter was never set by any caller. Change-Id: I668f78fe198f09fb0a9a52c10c8dea2fab070653 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDate: further optimize toString()Marc Mutz2015-03-261-11/+23
| | | | | | | | | | | | Factor the TextDate and ISODate legs into separate functions and replace a chain of QString::arg() with QStringBuilder. Saves 76B in text size. More importantly, restores (N)RVO for these code paths. Change-Id: I8b99bb672f5a4b5506d53487eca189d48b4025e9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTimePrivate: replace out parameters with return-by-value in getDateTime()Marc Mutz2015-03-251-34/+33
| | | | | | | | | | | | Compilers don't like out parameters. Effects on Linux GCC 4.9 stripped release builds: text -584B data +-0B relocs +-0 Change-Id: Ie00c89b9edaced3a6adeb2707734c8f5238e67c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: prevent aggressive inliningMarc Mutz2015-03-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function getDateFromJulianDay() is simple arithmetic, but still ~400 bytes in executable size. Yet GCC inlines this everywhere I looked, which makes some sense, as different users of the class only use parts of the return value and the optimizer has a field day removing all that dead code. However, that function has only one conditional, so presumably it executes at full pipeline speed and it doesn't matter that it calculates too much in some cases. More important is to use the I-cache more conservatively. That's what not inlining the function achieves. The function returns its result in registers and doesn't spill registers when called (at least on AMD64), so the effect on runtime should be negligible. Effects on Linux GCC 4.9 stripped release builds: text -1536B data +-0B relocs +-0 Change-Id: Ia16838102d29ad67ee5efdc8b7b0a26f2f921df1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTime: optimize toString()Marc Mutz2015-03-251-3/+1
| | | | | | | | | | | | | Instead of using a QString::arg() cascade, which creates tons of temporaries, use good 'ol sprintf(). Effects on Linux GCC 4.9 stripped release builds: text -308B data +-0B relocs +-0 Change-Id: I348577491d1399b5040f7ed9e9f6b111a9528e5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Micro-optimize QDate::{long,short}{Day,Month}Name()Marc Mutz2015-03-251-32/+28
| | | | | | | | | Save one return statement per function. I don't see why the compiler can't fuse these itself, but apparently it cannot, since this transformation saves 72B in text size. Change-Id: I3a661456554bf451ed53110ad546946ff7b84ec5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDate: don't spend code size covering the impossible caseMarc Mutz2015-03-251-1/+1
| | | | | | | | | | | | All other similar functions in QDate just return an empty string in case none of the switch labels would trigger (which would now cause a compiler warning, after removing the default case label), so do that here, too. Saves 44B in text size. Change-Id: I80ee4975082706adcd15fe89511d08c67e149324 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDate: remove some useless default case labelsMarc Mutz2015-03-251-8/+0
| | | | | | | | | | | | They're pure whitespace, since in each case there is a fallback after the switch, anyway, and their presence prevents compiler warnings about unhandled enumeration values in switch statements, which is nice-to-have, when adding to the enum, eventually. No change in executable code size. Change-Id: I77aecaeff990601f957ec9ee827eff5ead25aaa1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: ensure we always use the daylight status if knownThiago Macieira2015-03-111-19/+28
| | | | | | | | | Refactor the code so that the localMSecsToEpochMSecs function always gets the daylight status as input. The calculation can be very wrong if we forget to set it. Change-Id: I39e2a3fa6dc7c4a417f23288f10b303e450b8b98 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* Fix regression in time zone handlingFrederik Gladhorn2015-03-111-0/+1
| | | | | | | | | | | | In QtScript we use the msecs since epoch conversion (JS date is based on the concept). After a8c74ddcf78604c9038ba2a2bea81e445e4b3c58 the date conversion test in qtscript started to fail. Instead of relying on the code working by chance, simply update the date when setting it with setMSecsSinceEpoch. Task-number: QTBUG-44885 Change-Id: I9f95c9cdccea52e7d1f808f3cb9e18570ef0df13 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify calculation of week numberLars Knoll2015-03-101-50/+17
| | | | | | | This also removes a dependency to 3rd party licensed code. Change-Id: Ia4818a5cf306501bdb7192265edc4bcba8e597d8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Fix race condition in QDateTime::timeZone() and other methodsThiago Macieira2015-03-071-25/+30
| | | | | | | | | | | | | | | | | | | | When timezone support for QDateTime was added, we decided it was a good idea to delay creating the QTimeZone object and checking that the time is valid in that timezone (including for local time) until the user requested that information. Unfortunately, QExplicitlySharedDataPointer returns a non-const T* in operator->(), which meant we were accidentally modifying the d pointer's contents in const methods, which in turn means those const methods were not thread-safe when operating on the same object. This commit changes the d pointer to QSharedDataPointer, which is safer in this regard and pointed out where the issues with constness were located. Since we can't lazily calculate QTimeZone anymore, we need to do it whenever the date, time or offset changes. Task-number: QTBUG-43703 Change-Id: Ic5d393bfd36e48a193fcffff13b9686ef4ef1454 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QDateTime: cache the result of date.timeSpec() in QDebug op<<Marc Mutz2015-02-211-2/+3
| | | | | | | Saves a couple dozen bytes in text size on optimized AMD64 builds. Change-Id: Iefd9ca05a7b27f240836c1e1e00df569742fcd7f Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QDateTime: drop quotes in QDebug outputMarc Mutz2015-02-211-1/+2
| | | | | | | | | As requested in review of 1d2efe1f27bedcbaa157ef4e82b8eda33dda46ad. I didn't add a comma in front of the timeSpec() as the other fields aren't separated by commas, either. Change-Id: I54d74b7199ca7e46e28d2ceca22b02205e318c90 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QDate: optimize QDate::toString()Marc Mutz2015-02-171-3/+1
| | | | | | | | | | | | | Instead of using a QString::arg() cascade, which creates tons of temporaries, use good 'ol sprintf(). Effects on Linux GCC 4.9 stripped release builds: text -216B data +-0B relocs +-0 Change-Id: I6ff551cb9f42e0c05a64f03a8e177fb527915481 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: optimize toOffsetString()Marc Mutz2015-02-171-10/+6
| | | | | | | | | | | | | | | Instead of using a QString::arg() cascade, which creates tons of temporaries, use good 'ol sprintf(). As a consequence, this function is now inlined into all four callers and the total executable size _still_ goes down: Effects on Linux GCC 4.9 stripped release builds: text -420B data +-0B relocs +-0 Change-Id: I10d6abd94b489db7c2f01dc5424f30a798602522 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: replace out parameters with return-by-value in rfcDateImpl()Marc Mutz2015-02-171-66/+32
| | | | | | | | | | | | Compilers *really* don't like out parameters. (Impressive) effects on Linux GCC 4.9 stripped release builds: text -2512B data +-0B relocs +-0 Change-Id: I0fe370a438f7b82aaa9cc04ddd56e45a5969e7a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: optimize rfcDateImpl()Marc Mutz2015-02-171-20/+22
| | | | | | | | | | | | | Get the captured texts once and use indexing into the QStringList instead of repeatedly calling QRegExp::cap(n). (Impressive) effects on Linux GCC 4.9 stripped release builds: text -2876B data +-0B relocs +-0 Change-Id: I3a02eab1a691f31c30654cd89a0c030414b40de0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: change an instance of out parameters to return-by-valueMarc Mutz2015-02-171-52/+48
| | | | | | | | | | | | Compilers don't like out parameters. Effects on Linux GCC 4.9 stripped release builds: text -528B data +-0B relocs +-0 Change-Id: I32ee1a6c4388900bacfc6eb20feb4b81d71cb1f2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: micro-optimize QDebug op<<Marc Mutz2015-02-151-8/+5
| | | | | | | | | | | | | | | | Instead of constructing a QString that describes the QDateTime instance, stream the constituents of the string into QDebug directly, using op<< for Q_ENUM, now that it's available. Adapt test to new format of enums. Effects on Linux GCC 4.9 stripped release builds: text -1068B data +-0B relocs +-0 Change-Id: I1a5ce28904edd7d0f6c8d982fd41c52e3536e036 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Updated BSD licensed file headersJani Heikkinen2015-02-151-1/+1
| | | | | Change-Id: I6441ff931dbd33b698d762e6f6784898f3f60fe7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* QDateTime: make qt_monthNumberFromShortName() staticMarc Mutz2015-02-141-1/+1
| | | | | | | | | | | | It wasn't Q_DECL_EXPORT'ed, and there is no other user in QtCore. Effects on Linux GCC 4.9 stripped release builds: text -344B data +-0B relocs +-0 Change-Id: Iea0577d58057a145f87a00ec33995d03bacd4f88 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>