summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qdatetime.h
Commit message (Collapse)AuthorAgeFilesLines
* Use a QVector<QDateTime> instead of an array in QFileInfoPrivatehjk2013-04-231-0/+4
| | | | | | | | | | | | Since QDateTime is pimpled, default allocation is expensive and regularly shows up in profiles of code using QFileInfo. For Qt 6, QDateTime's data members should be put into the class proper, and this change here reverted. Change-Id: I94a50e467b12772e1076181eb2ac6031984d8802 Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Revert "Provide better error if min (or max) is defined in QDateTime"Jędrzej Nowacki2013-02-161-3/+0
| | | | | | | | | | | | | | This reverts commit d0804ff2dd3d289a0f0c58aa30c4334e66ea9be0. The commit breaks JSC which is used by QtWebKit, QtScript and indirectly by QtQuick1, which blocks integration stable->dev. JSC should be fixed upstream, but until then we need to revert the change. Change-Id: I3f7b8be08b68181e08422d2cb00d7cd70a7fc07f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Provide better error if min (or max) is defined in QDateTimeThorbjørn Martsum2013-02-021-0/+3
| | | | | | | | | This is better than getting a regular compiler error without knowing where min was previously defined. Change-Id: I5a86599cdf76a9a8d87a51e119543206d9f835c1 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix the gregorian date <-> julian day calculations in QDateJon Severinsson2012-11-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code is just plain wrong for negative julian days. Replaced with plain math from The Calendar FAQ [1], which is correct for all julian days, provided you use mathematical integer division (round to negative infinity) rather than c++11 integer division (round to zero). [1] http://www.tondering.dk/claus/cal/julperiod.php While the conversion code works for up to around JD +/- (2^63/4), we only use an int for the year in the API, so this patch limits minJd() and maxJd() to 1 Jan (2^31) BC and 31 Dec (2^31-1) AD, respectively. Note that while the new conversion code looks like it would be more expensive than the old, gcc will in fact be able to optimize it to be slightly faster (probably because x86 hardware implements round to negative infinity, and so GCC manages to optimize floordiv to a single instruction, compared to the three instuctions needed for operator/). In the following test application, run with a release mode Qt and redirecting stderr to /dev/null, I measured an improvement from 6.81s +/- 0.08s to 6.26s +/- 0.16s user time over five runs on an otherwise idle x86_64 system. int main(int, char *[]) { int year, month, day; qint64 jd; for (qint64 i = Q_INT64_C(-1048576) ; i < Q_INT64_C(1048576); ++i) { QDate::fromJulianDay(i).getDate(&year, &month, &day); jd = QDate(year, month, day).toJulianDay(); qDebug() << jd << year << month << day; } } Change-Id: Ifd0dd01f0027f260401f7f9b4f1201d2b7a3b087 Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change QDateTime::addSecs() and QDateTime::secsTo() to use qint64.Jon Severinsson2012-10-101-2/+2
| | | | | | | | | | addMSecs() / msecsTo() have always used qint64, and when QDate was changed to use a 64-bit julian day, QDateTime::addDays() and QDateTime::daysTo() was changed to use qint64 in order to support the full extended range, but addSecs() and secsTo() seems to have been forgotten. Change-Id: I3acc35ee2bcc9f353650eb42f97d428f706b2db6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Add Q_DECL_NOTHROW to some qHash functionsThiago Macieira2012-08-201-2/+4
| | | | | | | | | | | | The hashing functions for QDateTime and QHostAddress did not get the noexcept keyword because they might allocate memory. QDateTime doesn't do it now, but it could in the future. QHostAddress does allocate memory today. Change-Id: Ia5f80942944bfc2b8c405306c467bfd88ef0e48c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark QElapsedTimer functions as Q_DECL_NOTHROWThiago Macieira2012-08-091-1/+1
| | | | | | | | | | | | | | | | | | All functions in QElapsedTimer are marked Q_DECL_NOTHROW. This code is often introduced in many places to deal with timeouts and doesn't need exception handlers. In particular, it's used in QMutex locking. In addition, mark QDateTime::currentMSecsSinceEpoch as nothrow, as it can't throw exceptions either and it is needed by the generic QElapsedTimer. Q{Date,Time}::current{Date,Time} operate on local time and run into at least one cancellation point, which we must consider throwing. And returning a QDateTime allocates memory. Change-Id: Id776c5ec831fc06d7419a9ff5442d9b35cff1a22 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Write qHash functions for QDate, QTime and QDateTime.Mitch Curtis2012-07-121-0/+4
| | | | | | | | These functions didn't exist - this patch implements them. Task-number: QTBUG-23079 Change-Id: I9eb6e238531d5cda878f5f2cdd27bab30aa60669 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: mark some classes as sharedMarc Mutz2012-07-101-1/+1
| | | | | Change-Id: I811d3eebd87c230883cc579c20f9fa4e14ff9521 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: add member-swap to shared classesMarc Mutz2012-07-031-0/+2
| | | | | | | | | | Implemented as in other shared classes (e.g. QPen). Special case: QUrlQuery: document existing swap(). Change-Id: I4b36cc9577fbf2232d4b2a2d8822d26e41e22cad Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Partial fix for WebKit compilation on WindowsSimon Hausmann2012-06-131-9/+0
| | | | | | | | | | | | | | | | | | | | | | qdatetime.h uses std::min/max and on Windows windows.h (or some subsequent header file) may under certain circumstances define min/max as macros. The easiest way to prevent the windows header files from doing that is to define NOMINMAX in the place right before windows.h is included. The other way is to define min and max to min/max themselves to prevent windows.h from doing its evil thing. If a user of Qt (WebKit in this case) chooses the approach of defining min/max to themselves and then includes qdatetime.h, then a subsequent inclusion of windows.h doesn't work because qdatetime.h undefines min/max. We should not enforce the type of workaround needed, therefore this patch removes the workaround from qdatetime.h and requires user code that happens to include windows header files before qdatetime.h (seldom case) to choose either workaround. Change-Id: I7347eec7369491a065e894cff557004e069453d5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: Store Julian Day as qint64John Layt2012-02-051-10/+26
| | | | | | | | | | | | | | | Store the QDate Julian Day number as an qint64 instead of uint32 to enable support for dates before 2 January 4713 BCE. This changes the possible date range to be approx 2.5 Quadrillion BC to 2.5 Quadrillion AD. A qint32 was not used as it only covers 5 million BCE to 5 million CE which does include Geological or Astronomical time. The effective supported date range is currently 4800 BCE to 1.4 million CE due to restrictions in existing conversion formulas. The effective range will be extended later with new formulas. Change-Id: Ib4345369455b31d4edae8c933b7721e76414e914 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: Deprecate setYMD()John Layt2012-01-311-1/+5
| | | | | | Change-Id: I077332df554fb750666d51486c97724411276679 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove use of QT_MODULE from libraryGunnar Sletta2012-01-251-1/+0
| | | | | | | | | | These defines were there to aid in the commercial licensing scheme we used long ago, and are no longer needed. Keep a QT_MODULE(x) define so other modules continue compiling. Change-Id: I8fd76cd5270df8f14aee746b6cf32ebf7c23fec7 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Clean-up the interface for QDate.Xizhi Zhu2012-01-091-13/+4
| | | | | | | | | | | | | | | | Four overload functions removed while keeping source compatibility: - shortMonthName() - shortDayName() - longMonthName() - longDayName() Two functions removed since they have confusing names: - gregorianToJulian() - julianToGregorian() Change-Id: Iaaea066a3fb77b1ee3499d3049fcec5563054cdf Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: John Layt <jlayt@kde.org>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* remove QT3_SUPPORT from corelib/toolsLars Knoll2011-06-291-48/+0
| | | | | | | Change-Id: Ie224cf992be675c7d405d4be05e4acd4157e590e Reviewed-on: http://codereview.qt.nokia.com/863 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Liang Qi <liang.qi@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+340
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12