summaryrefslogtreecommitdiffstats
path: root/src/corelib/time/qdatetime.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Distinguish invalid datetimes from othersEdward Welbourne2019-10-111-11/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | A default-constructed QDateTime is invalid, but compared equal to a valid one referencing the start of 1970. This lead to date properties in QML being initialized invalid but not getting an onChange if the first value they're set to is the start of 1970. Fixing that then lead to some tests failing. Indeed, the original equality check involved using toMSecsSinceEpoch(), whose value is undefined unless the datetime is valid, without a prior check on its validity: so ensure all uses of toMSecsSinceEpoch() are guarded with isValid() checks. Reworked tst_QDateTime::toSecsSinceEpoch() to use its bool column (previously unused, after separating from toTime_t(), which uses this column for "out of time_t's range") for validity of the datetime. [ChangeLog][QtCore][QDateTime] Invalid datetimes are now treated as equal and less than all valid ones. They could previously be found equal to valid datetimes. Fixes: QTBUG-79006 Change-Id: Ie72deb8af4350a5e808144d0f6e42dc8eb3ff5ef Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix doc of QDateTime::YearRange; include its \since 5.14Edward Welbourne2019-09-271-0/+1
| | | | | Change-Id: I2e6c27953ecce95df3ac4868a6d953596ba115f2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc-fix: correct some misinformation about QDateTime's handling of DSTEdward Welbourne2019-09-131-23/+30
| | | | | | | | | | | | | | Tidy up QDateTime::offsetFromUtc's doc, in the process. We don't take DST into account for dates before the epoch; that should be mentioned when saying we take DST into account. Also, referring to *this as the "current" time begs to be misunderstood. The \class comment also misleadingly claimed that we don't take into account any changes to time-zone before DST; where, in fact, we only ignore DST changes before 1970, not changes to standard offset. Change-Id: I090e668edf0338c825f5afcc67f894579a129c46 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Fix some qdoc warnings in 5.14Friedemann Kleint2019-09-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark QCalendarBackend as internal since it is in a private header and fix some issues in the QCalendar related classes. src/corelib/time/qcalendar.cpp:201: (qdoc) warning: clang found diagnostics parsing \fn int QCalendarBackend::daysInMonth(int month, int year) const error: incomplete type 'QCalendarBackend' named in nested name specifier (repeats) src/corelib/time/qdatetime.cpp:1426: (qdoc) warning: Unknown command '\override' (repeats) src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'Last' in QCalendar::System src/corelib/time/qcalendar.cpp:642: (qdoc) warning: Undocumented enum item 'User' in QCalendar::System src/corelib/time/qcalendar.cpp:744: (qdoc) warning: Undocumented parameter 'year' in QCalendar::isLeapYear() src/corelib/time/qcalendar.cpp:923: (qdoc) warning: Can't link to 'dateTimeString()' (repeats) src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'year' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'month' in QCalendar::partsFromDate() src/corelib/time/qcalendar.cpp:893: (qdoc) warning: No such parameter 'day' in QCalendar::partsFromDate() src/corelib/time/qdatetime.cpp:1425: (qdoc) warning: Undocumented parameter 'nmonths' in QDate::addMonths() src/corelib/time/qdatetime.cpp:1467: (qdoc) warning: Undocumented parameter 'nyears' in QDate::addYears() src/corelib/statemachine/qstatemachine.cpp:2522: (qdoc) warning: Undocumented enum item 'StateMachineChildModeSetToParallelError' in QStateMachine::Error src/corelib/kernel/qtimer.cpp:602: (qdoc) warning: Undocumented parameter 'connectionType' in QTimer::callOnTimeout() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'name' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:159: (qdoc) warning: Undocumented parameter 'id' in QCalendarBackend::QCalendarBackend() src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'registerCalendar()' src/corelib/time/qcalendar.cpp:529: (qdoc) warning: Can't link to 'fromName()' src/corelib/time/qcalendar.cpp:178: (qdoc) warning: Can't link to 'QCalendar::fromEnum()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Undocumented parameter 'jd' in QCalendarBackend::dayOfWeek() src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'weekDayName()' src/corelib/time/qcalendar.cpp:405: (qdoc) warning: Can't link to 'standaloneWeekDayName()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:268: (qdoc) warning: Can't link to 'isLeapYear()' src/corelib/time/qcalendar.cpp:295: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLuniSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isSolar()' src/corelib/time/qcalendar.cpp:313: (qdoc) warning: Can't link to 'isLunar()' src/corelib/time/qcalendar.cpp:340: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:357: (qdoc) warning: Can't link to 'daysInMonth()' src/corelib/time/qcalendar.cpp:544: (qdoc) warning: Can't link to 'fromName()' Change-Id: Ia2fabefb917f8e4cfa361044d9b754717276f4aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Optimize QDate by shortcutting some gregorian calendar methodsEdward Welbourne2019-08-301-14/+93
| | | | | | | | | | Add some static methods to QGregorianCalendar, some of which serve to implement its methods, that QDate can use to bypass vtables and exploit fixed truths of the Gregorian calendar in its default handling. Change-Id: Iec191cdf4d52945dbd5679e609180cb4fe59b5fd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add support for calendars beside GregorianSoroush Rabiei2019-08-201-256/+361
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add QCalendarBackend as a base class for calendar implementations and QCalendar as a facade via which to access it. QDate's implicit implementation of the Gregorian calendar becomes QGregorianCalendar and QDate methods now support choice of calendar. Convert QLocale's CLDR data for month names to a locale-data component of each supported calendar and relevant QLocale methods now support choice of calendar. Adapt Python scripts for locale data generation to extract month name data from CLDR (keeping on version v35.1) into the new calendar-locale files. The locale data for the Gregorian calendar is held in a Roman calendar base, for sharing with other calendars. Add tests for basic uses of the new API. [ChangeLog][QtCore][QCalendar] Added QCalendar to support diverse calendars, supported by implementing QCalendarBackend. [ChangeLog][QtCore][QDate] Allow choice of calendar in various operations, with Gregorian remaining the default. Done-with: Lars Knoll <lars.knoll@qt.io> Done-with: Edward Welbourne <edward.welbourne@qt.io> Fixes: QTBUG-17110 Fixes: QTBUG-950 Change-Id: I9d6278f394269a183aee8156e990cec4d5198ab8 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Simplify QDate::weekNumber() by looking at the right day of the weekEdward Welbourne2019-08-071-27/+14
| | | | | | | | | The Thursday in the same week has the same week-number and determines the right year to use for the week. So calculate its week-number and save a whole lot of complications. Change-Id: I9c28267e6083afdd04a15245e1609c64beb82b37 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port from QStringViewLiteral to u""Marc Mutz2019-07-291-4/+4
| | | | | | | | | Now that all our supported compilers know char16_t, we no longer need QStringViewLiteral, whose only purpose in life was to turn u"" into L"" for MSVC < 2015. Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix typo: s/QLocal/QLocale/Edward Welbourne2019-07-261-1/+1
| | | | | | | | | This amends commit 1d8c9978fa1baafa17c95713bd5d04f245eeb76f in which I perpetrated this typo. Change-Id: Iccfc14aff7c4f3976b92919c8e8dc4b7906642ae Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-191-21/+13
| | | | Change-Id: I999ba23a27cd897017d15c6ffe41ea8cd008ffb9
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-101-4/+3
| | | | | | | | Conflicts: src/corelib/time/qdatetime.cpp src/widgets/widgets/qcombobox.h Change-Id: Ib84352e8fe34aed2986a1c94e7346a46a71c803b
* Move YearRange to QDateTime from its PrivateEdward Welbourne2019-07-011-2/+21
| | | | | | | | | | | | | | | | | As planned when adding YearRange: now that it's merged up to dev, move it to QDateTime, since we can add to the API at 5.14.0. This follows up on commit 82ad4be4a2e0c2bccb6cd8ea2440aefee4ec48ec. Change-Id: I81b6c2331121a71e2592514781c02c5756e70c52 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* rtems: Fix build qdatetime.cppMikhail Svetkin2019-06-301-1/+1
| | | | | | | | | | | | | | | | RTEMS does not have "timezone" global variable. Change-Id: Ifa4c6f8939270a83fb7b5ba623daafa1e9f81003 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix qdoc warnings in 5.14Friedemann Kleint2019-06-281-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | Fix warning: src/corelib/global/qnamespace.qdoc:2371: (qdoc) warning: Cannot find 'Qt::SplitBehavior' specified with '\enum' in any header file and qdoc getting confused by a link spanning lines: src/corelib/time/qdatetime.cpp:3324: (qdoc) warning: Unknown macro 'note' src/corelib/time/qdatetime.cpp:3326: (qdoc) warning: Unknown macro 'section1' src/corelib/time/qdatetime.cpp:3328: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3334: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3344: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3361: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3373: (qdoc) warning: Unknown macro 'e' src/corelib/time/qdatetime.cpp:3378: (qdoc) warning: Unknown macro 'section2' src/corelib/time/qdatetime.cpp:3386: (qdoc) warning: Unknown macro 'sa' Change-Id: I314da69078eb07f66e9d389eecdf0195569ea2ce Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Port from QAtomic::load() to loadRelaxed()Giuseppe D'Angelo2019-06-201-3/+3
| | | | | | | | | | | | | | | Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-06-141-96/+103
| | | | | | | | | | Conflicts: qmake/generators/makefile.cpp qmake/generators/unix/unixmake2.cpp src/corelib/thread/qthread_unix.cpp tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: I1df0d4ba20685de7f9300bf07458c13376493408
* Rearrange date parsing in anticipation of calendar workEdward Welbourne2019-06-071-34/+29
| | | | | | | | | | | | | The calendar APIs shall need fromShortMonthName() to know its year number; so rearrange the date parsing that uses it to ensure the year number is known in time. In the process, pass &ok to toInt() also for the calls that get a day number (where failure's 0 return is an adequate check for failed parse), just to be on the safe side. Change-Id: Id09c40da9f7e70e68be440e9805a3d30a80977c6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-15/+15
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Separate out the time, zone, date code from corelib/tools/Edward Welbourne2019-06-061-0/+5685
We'll be adding calendar code here as well, and tools/ was getting rather crowded, so it looks like time to move out a reasonably coherent sub-bundle of it all. Change-Id: I7e8030f38c31aa307f519dd918a43fc44baa6aa1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>