summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
Commit message (Collapse)AuthorAgeFilesLines
* Remove an extraneous section in the documentation of QRomanCalenderThibaut Cuvelier2022-07-261-5/+4
| | | | | | | | | | | | This section didn't even have a title. History suggests that it never had a title and does not indicate why it is needed. Commit introducing the change: aa8393c94fea01a4806b204fd3aa343a4e90666b Also, improve the wording of the class description. Change-Id: I95dbb851f10e6562f3c8875cb0e237fa4334ffc1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make locale data arrays constexprMarc Mutz2022-07-203-6/+6
| | | | | | | | | | Weirdly, the generator script already has these arrays all as constexpr... Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-100485 Change-Id: I66d54e097cac1fb6399adfeac155f1e46ff525de Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtBase: eradicate QT_STRINGVIEW_LEVEL usesMarc Mutz2022-07-201-12/+0
| | | | | | | | | | | | It's not used and not useful. The macro itself has to stay, for now, because Qt5Compat uses it, too. Task-number: QTBUG-100861 Pick-to: 6.4 6.3 6.2 Change-Id: I5d0557a6c959d6facf6e47f26786a9d365339e95 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDateTime: remove a few hardcoded values in favor of <chrono> constantsThiago Macieira2022-06-271-5/+8
| | | | | Change-Id: I6d3880c7d99d4fc494c8fffd16fb01b9d9480c67 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDateTime::Data, QTimeZone: rule-of-five and noexceptEdward Welbourne2022-06-084-6/+17
| | | | | | | | | | | | CodeChecker noted that both QDateTime::Data and QTimeZone have incomplete rule-of-five method sets; and two of the former's methods should be noexcept. Marc tells me the copy constructor can be noexcept. Added the missing methods and noexcepts. Change-Id: I8ddaa86207320606a890e90bd2b1593ee82f5a4a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* PosixZone::parse(): don't reset already-initialized variableEdward Welbourne2022-06-081-2/+1
| | | | | | | | | | | The nameBegin variable was already initialized to pos, so just increment it in the one case that needs it rather than resetting it in both branches of the condition. Change-Id: Ia0d42b604ed21829dc84c27a1907c345f62594d1 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Drop const from a declaration to let a return moveEdward Welbourne2022-06-081-1/+1
| | | | | | | | | | | | | CodeChecker points out that QTimeZone::systemTimeZoneId()'s first attempt saved its result in a const QByteArray, which consequently wasn't moved from when returning. That doesn't make a huge difference for a CoW, but might as well skip the const and let the compiler do the natural thing. Change-Id: I966c9137505a8188532b164524dd4e05c0b2ac53 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Don't std::move() trivally-copyable type; it makes no differenceEdward Welbourne2022-06-081-6/+7
| | | | | | | | | | | | | | CodeChecker says: std::move of the variable 'parts' of the trivially-copyable type 'QCalendar::YearMonthDay' has no effect; remove std::move() So don't bother with the move, and remove && from the signature of the function being called in all four places. Assert that the type *is* trivially copyable. Change-Id: I3c07491b4b1dafdf52916e8699561c58c24ee954 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Simplify construction of two QTime instancesEdward Welbourne2022-06-031-4/+2
| | | | | | | | | Rather than default-constructing and later setting its .mds, just pass the number of millis to the constructor. Change-Id: I5e259ee99b1ba53c48d8d71f2b479001c26ab7a0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add MINS_PER_HOUR constant and avoid a Coverity overflow warningEdward Welbourne2022-06-033-13/+19
| | | | | | | | | | | | | | | | Being able to distinguish which 60 is minutes-per-hour and which is seconds-per-minute has some value in its own right, and doing it with qint64 values (as usual for DateTimeConstants) takes care of two Coverity warnings about multiplying before widening. Use the new constant, and SECS_PER_MIN, in a few other places where the result isn't an int (we don't want to provoke narrowing warnings). Change-Id: Iadcb6956ac22a53029bf7b7518369520d2b1fd8b Coverity-Id: CID 393112 Coverity-Id: CID 393113 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Core: make CLDR data constexprYuhang Zhao2022-05-271-5/+5
| | | | | | | Task-number: QTBUG-100485 Pick-to: 6.3 6.2 Change-Id: Ib8c5160ca0994662a5fdc2293dc734c1bdcac4f2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Implement in QLocalTime the offset functions V4 Date needsEdward Welbourne2022-05-222-0/+56
| | | | | | | | | | | | Prepare to replace a large pile of #if-ery-laden tangled mess from the implementation of V4 Date by implementing a cleaned-up version of one of its offset calculations and using a recently refactored API of QDTP to implement the other. Task-number: QTBUG-95993 Change-Id: I469f67fb384543abeece9ce8b14bb294c8613033 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move remaining time_t code from qdatetime.cpp to QLocalTimeEdward Welbourne2022-05-204-338/+338
| | | | | | | | | | What remains is all tangled together, but is now at least decoupled from the rest of qdatetime.cpp, so moving it out makes that file easier to read. Task-number: QTBUG-95993 Change-Id: I3fba15aea59b3c8b4cbc6bf1cb03de96d68db0ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Split qtLocalTime out into a new QLocalTime namespaceEdward Welbourne2022-05-204-77/+159
| | | | | | | | | | | | | | | ... in new qlocaltime* files, now that it's decoupled enough from the internals of QDateTime for this to be possible. Part of the consolidation of time_t code in one place. Move assorted constants from qdatetime.cpp to a private namespace in qdatetimeprivate_p.h to be shared between q*time.cpp hereafter (fixing an out of date comment in the process - julianDayFromDate() is long gone). Task-number: QTBUG-95993 Change-Id: I03d97e959118041f9d86b8bb2e738599bc0b17e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace qt_mktime(), avoiding out-parameters and conversionsEdward Welbourne2022-05-201-115/+131
| | | | | | | | | | | | | | | | | | | Since qt_mktime() took QDate and QTime in/out parameters, its callers had to convert the milliseconds they had to that form and back again after. Since it combined optional look-up of zone abbreviation with determination of offset and DST-ness (both ignore when the abbreviation was asked for) it made sense to split it in two. Each takes the millis and whatever knowledge we have of DST. One returns tha abbreviation; the other returns a QDTP::ZoneState for the caller that'll be returning that. Outside the system zone, when we have to fall back to a kludge, their callers can now use the Julian Day number change for its fake date to directly adjust the millis there and back (effectively inlining former conversions to-and-from date and time representation, but optimising out some of the work). Change-Id: I7aa4583171f77fc0f4aa80c8f564e76995ca69d2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Eliminate the msecsToTime() overload with out-parametersEdward Welbourne2022-05-201-26/+12
| | | | | | | | | | Now that I've disposed of the callers that were or might be passing null pointers for the out-parameters, getDateTime() can inline its computation and the two other callers can use msecsTo{Date,Time} until I eliminate the need for that. Change-Id: Ia9169779cf03189fc7fd5271044d1ec90089fa03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor QDateTimePrivate::*MSecsToEpochMSecs()Edward Welbourne2022-05-202-154/+148
| | | | | | | | | | | | | | | | | | | | Aside from one client that wanted the zone abbreviation for a given local time (and could supply a DST-ness hint), the callers actually want to know the offset from UTC, DST-ness and any correction needed to the local time to dig it out of a spring-forward. Mediating all of that via a QDate, a QTime and a returned UTC seconds since the epoch was not making our lives any easier. Split the local-time function into one to get the abbreviation and another to determine the data we actually need. The zone version only needs the latter. Two functions with hairy signatures replete with in/out parameters are replaced with three, with no in/out parameters. Adapt all callers of the old functions to use the new, simplifying them in the process. Inline some conversions between date+time and msecs in the process. Change-Id: Ice60b615121a99111ed882734785fa3c777e191c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor qt_localtime()Edward Welbourne2022-05-201-85/+87
| | | | | | | | | | | Break out the part that calls the appropriate platform variant, so that the logic of what we do with the result of that isn't tangled up with the #if-ery. Rework the remainder to return a struct type that packages the data we need, to get rid of the three out-parameter pointers. Change-Id: Ibba6f8de0954fab3fddf9e95adc18ef85e45ff72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime::setMSecsSinceEpoch(): push more work into a helper functionEdward Welbourne2022-05-202-67/+84
| | | | | | | | | | | | | | | | | | | Formerly, setMSecsSinceEpoch() passed a QDate and a QTime to epochMSecsToLocalTime() as in/out parameters, then obtained what it actually wants, a count of milliseconds, from their modified values and computed an offset from that. Pass the epoch milliseconds from which the QDate and QTime were derived in place of them and return the local milliseconds, offset and DST status back in a structure, rather than via pointer parameters. This prepares the way for pushing one step further, back into qt_localtime(), so that we can simply get the count of milliseconds, along with DST flag and offset from UTC, without going via QDate and QTime (except in the kludge that copes with times outside the time_t range; and even that can be short-cut somewhat). Change-Id: I37ebb1efb355e81e1a116d03cbd52f9bb4a1f114 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix wrong QDateTime::isValid() to use the right QFlags methodEdward Welbourne2022-05-201-1/+1
| | | | | | | | | | It's documented to return true "if both the date and the time are valid and they are valid in the current Qt::TimeSpec" but it was using testAnyFlag() so would have returned true if any one of the three conditions was met, rather than only if all three are met. Change-Id: I91746224009d820abaffb541d8f6d6b13142849b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify msecsToTime() and two callers by using QRoundingDownEdward Welbourne2022-05-201-24/+19
| | | | | | | | | | | | | The formerly cumbersome arithmetic, to adjust for division rounding towards zero rather than down, is so much simpler this way. Break out the conversion for only date and for only time, for the sake of (for now) two callers that only need one; and inline QRoundingDown::qMod() to save repeating the qDiv() call. Include the mapping from millis to raw Julian Day as a separate function, as I'll be using it shortly. Change-Id: I0ee74ea68421a347ed618fa34142bd034844351e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-1636-1381/+85
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Refine QRoundingDown::qDiv() to avoid underflowEdward Welbourne2022-05-061-2/+9
| | | | | | | | | | Subtracting denominator - 1 from the numerator ran into trouble if the numerator was close to its type's minimum representable value. Adding 1 before division, then subtracting it after, avoids that underflow while getting the same answer. Change-Id: I0bb85deaa2ad36f8744ed6dbfdb4817442dddebe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct leap year sequence in systemTimeYearMatching()Edward Welbourne2022-04-251-1/+1
| | | | | | | | | | In the sequence for the early 32-bit time_t leap years, I somehow managed to get two of the entries swapped. This amends commit 1f4b237dade9d0d2ed5439e3834ac22985797561 Pick-to: 6.3 Change-Id: I5cb9080f8c6a24e2163508e640747c6fbbe93dbd Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Exploit the new macro varargs form of Q_GLOBAL_STATICEdward Welbourne2022-04-221-2/+2
| | | | | | | | Convert various uses of Q_GLOBAL_STATIC_WITH_ARGS() to the less verbose form the recent reworking makes possible. Change-Id: I57820660b5d00d39bf54b5a08cb921ebaec57c7c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDate(Time): add a addDuration methodGiuseppe D'Angelo2022-04-142-0/+53
| | | | | | | | | | | | | | | | To complement the existing addSecs / MSecs / etc., add a function that takes any compatible std::chrono::duration. QTime also features similar functions, but it's also "unique" in that it uses modular arithmetic (it wraps around in case of "overflow"). I'm not so sure that adding durations to a QTime object therefore makes sense, and I'm not doing it in this patch. [ChangeLog][QtCore][QDate] Added addDuration(). [ChangeLog][QtCore][QDateTime] Added addDuration(). Change-Id: I02aa37ff024d7f56fa976dc8f4f73523bdba8d94 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: add conversions for time_point and zoned_timeGiuseppe D'Angelo2022-04-133-0/+151
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In C++20, QDateTime is a direct equivalent of a sys_time<milliseconds> time point. (Before, it might not have been, because system_clock before C++20 was not guaranteed to be tracking Unix time, AKA UTC time without leap seconds.) To be specific, sys_time<milliseconds> corresponds to a QDateTime using the Qt::UTC timespec. This patch: 1) adds named constructors taking time_points: * a generic one taking any time_point convertible (via clock_cast) to a system_clock (this obviously includes system_clock, but also e.g. utc_clock) * another couple taking local_time, interpreted as a duration from 1/1/1970 in local time. 2) adds a named constructor from zoned_time (i.e. a sys_time + a timezone), that we can easily support via QTimeZone. 3) add conversion functions towards sys_time, matching the existing to(M)SecsSinceEpoch() functions. [ChangeLog][QtCore][QDateTime] QDateTime can now be constructed from std::chrono::time_point objects (including local_time), as well as from std::chrono::zoned_time objects. Moreover, they can be converted to std::chrono::time_point using system_clock as their clock. Change-Id: Ic6409bde43bc3e745d9df6257e0a77157472352d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDate: add conversions for std::chrono calendaring classesGiuseppe D'Angelo2022-04-132-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::chrono::year_month_day and related classes offer very convenient to specify dates. This patch adds implicit constructors to QDate to support this convenience, e.g.: // YYYY-MM-DD, DD-MM-YYYY, MM-DD-YYYY formats: QDate d1 = 1985y / December / 8; QDate d2 = 8d / December / 1985; QDate d3 = December / 8d / 1985; // Indexed weekday: QDate d4 = 2000y / January / Monday[0]; QDate d5 = 2000y / January / Monday[last]; and so on. These are all implemented using the conversion from the std calendaring classes to sys_days. Conversions between sys_days and QDate are also added, since they're basically "for free". I don't expect "ordinary" users to stumble upon it, but it's worthy mentioning that std::chrono::year *does* have a year zero (hence, year_month_day in year 0 or below are offset by one with the corresponding QDate). I've left a note in the documentation. [ChangeLog][QtCore][QDate] QDate (and therefore QDateTime) is now constructible using the year/month/day/week classes available in the std::chrono library. Moreover, it now features conversions from and to std::chrono::sys_days. Change-Id: I2a4f56423ac7d1469541cbb6a278a65b48878b4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: add support for std::chrono::duration arithmeticGiuseppe D'Angelo2022-04-132-0/+102
| | | | | | | | | | | | | | | | | | | QDateTime represents a specific point in time, so arithmetic with durations makes perfect sense. Moreover, we can finally equip QDateTime with a subtraction operator, to calculate the duration between two QDateTime objects. [ChangeLog][QtCore][QDateTime] QDateTime now supports arithmetic between QDateTime objects and std::chrono::duration objects. A duration can be added to or subtracted from a QDateTime, yielding another QDateTime; and two QDateTime objects can be subtracted from each other, yielding the duration between them. Change-Id: I656419f3bb9418c49f0e2fd0800c3dbaaf6aff32 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone: add construction from std::chrono::time_zone*Giuseppe D'Angelo2022-04-122-0/+22
| | | | | | | | | | | A time_zone represents a timezone identified by its IANA ID. This allows for a straightforward conversion to QTimeZone. [ChangeLog][QtCore][QTimeZone] QTimeZone can now be constructed from a std::chrono::time_zone pointer. Change-Id: I093d9fc2e989475d30730a9dcdef491903a2aeb2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update CLDR-derived data to newly-released v41Ievgenii Meshcheriakov2022-04-084-2744/+2764
| | | | | | | Fixes: QTBUG-101214 Change-Id: I42f3e76d03b4759d3cda9ab81856d0b6d7506d8e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Android: minor refactor in QTimeZonePrivate backendIvan Solovev2022-04-081-6/+5
| | | | | | | | | | getDisplayName() now returns QString instead of QJniObject. It's more clear and allows to save some QJniObject::toString() calls in other parts of code. Pick-to: 6.3 6.2 Change-Id: I0f2061cf1dff21c09c2272bf1e9126ff1ea0ed3e Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Android: use BCP 47 tag to create a correct Locale for QTimeZone::displayName()Ivan Solovev2022-04-081-11/+4
| | | | | | | | | | | | | | | | | | Before the patch we tried to create a java Locale object by passing the human-readable language, territory and variant strings. However, the Locale constructor accepts ISO-defined codes. Fix it by using a factory method Locale.forLanguageTag() [0] that constructs a Java Locale object based on BCP 47 tag. [0]: https://developer.android.com/reference/java/util/Locale#forLanguageTag(java.lang.String) Fixes: QTBUG-101460 Pick-to: 6.3 6.2 5.15 Change-Id: If414c66cf0e5b7e8299ffc3a6038b6f9eb79d5ec Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Fix assertion failure when parsing a doubly-invalid date-time textEdward Welbourne2022-04-071-3/+8
| | | | | | | | | | | | | | | | | | | | | | | When the date-time string falls in a spring-forward (so is invalid) and one of the fields of the parsed string doesn't match the format it's meant to (e.g. a single-digit seconds field when format ss was specified), a check that the current fall-back date-time is between the minimum and maximum for the parser object failed, triggering an assertion. In any case, an invalid default-value wasn't useful to the code that parsed a single section of the date-time string, so brute-force the current value to a valid date-time (when possible) using the usual round-trip via milliseconds since the epoch. Added the test-case which first revealed the problem, plus a couple more informed by it, to exercise the same code-paths with fewer things failing. Fixes: QTBUG-102199 Pick-to: 6.3 6.2 5.15 Change-Id: I658308614505ef25f4c97d0de6148acb54a65a0f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix overflow issue discovered by MSVC in C++20 modeEdward Welbourne2022-04-051-2/+3
| | | | | | | | | | | | | | | | | | In setMSecsSinceEpoch(), when epochMSecsToLocalTime() fails (e.g. when msecs is near one end of time and the offset being added causes overflow), the call to setDateTime(d, ...) is bypassed so the d-ptr is not updated and getStatus(d) returns the status prior to the function call. The new status being prepared by the function should thus not be updated to getStatus(d) unless setDateTime(d, ...) was called. This amends commit 74eddd5bf0672db4edd190aefd813bcf7eb26df4 Done-with: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Fixes: QTBUG-102157 Pick-to: 6.3 Change-Id: I25e358070907f22d9e4fb0030fa82ec290c7a730 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Minor post-""_L1-ification tidy-up in QDateTimeParserEdward Welbourne2022-04-051-7/+5
| | | | | | Change-Id: Ibbead3922446b820bfe6def5f1278fd7825f0425 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDateTimeParser: Correct a comment which was exactly wrongEdward Welbourne2022-04-051-1/+1
| | | | | Change-Id: I90c2b2bce4aeb5fe9edf70122c6546976583e1bf Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Apply Q_CONSTINIT across the codebaseMarc Mutz2022-03-291-1/+1
| | | | | | | | | Still not complete. Just grepping for static and thread_local. Task-number: QTBUG-100486 Change-Id: I90ca14e8db3a95590ecde5f89924cf6fcc9755a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live Q_CONSTINIT!Marc Mutz2022-03-261-1/+1
| | | | | | | | | | | | | | | | | | It expands to the first available of - constinit (C++20) - [[clang::require_constant_initialization]] (Clang) - __constinit (GCC >= 10) Use it around the code (on and near static QBasicAtomic; this patch makes no attempt to find all statics in qtbase). [ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT. Fixes: QTBUG-100484 Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-265-7/+8
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-256-67/+76
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* Enable QIcuTimeZonePrivate's support for transitionsEdward Welbourne2022-03-251-15/+10
| | | | | | | | | | | | | | The support was previously limited to ICU version 50, with an == check rather than a >= one, accompanied by a TODO comment to check whether the API was stable at 51. Nine years have passed since ICU 51 was released, we're now up to release 70, and now I've finally verified that the API is stable (and fixed a few bugs in how we use it). So change the check so that we now do use the transition API. Fixes: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: Ica024b6c28a213e0de0a37f196839e8ded193889 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix QIcuTimeZonePrivate::data() before the first transitionEdward Welbourne2022-03-251-6/+8
| | | | | | | | | | Provide valid data, since ICU can, by the means we used before the transition API was introduced. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I4d4a1201db2255b98901dacb83169ae4ae25ef05 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix QIcuTimeZonePrivate::hasDaylightTime() to catch historical DSTEdward Welbourne2022-03-251-2/+11
| | | | | | | | | | | | | QTimeZone::hasDaylightTime() is documented to return true if a zone has ever dabbled in DST, but the ICU implementation was only detecting whether the zone currently engages in it. When the transitions API is available (currently for version == 50; will soon change to >= 50), use it to find out whether DST was ever in effect. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I4576de2e074dc57b54450b1e40a23358ccf0ef49 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix ICU's handling of last representable transitionEdward Welbourne2022-03-251-1/+9
| | | | | | | | | | | | | | | ICU's search for next transition, when the result would lie later than is representable by qint64, returns the last transition before the bound, even if this is at the time it was meant to exclude from the range searched. This lead to infinite looping when we tried to traverse transitions forward. Recognize when this happens and return the invalid data object that indicates falling off the end of time instead. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I1a210fb7a4086b2fdb052b2260c800bfc29f965a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Apply the East-Saskatchewan exception to zone-fragment lengths to ICUEdward Welbourne2022-03-251-5/+9
| | | | | | | | | | | | The exception was previously limited to Android, but I now find that ICU has the same over-long names; it seems likely that's where Android gets them. Also update the link to the theory page from the TZ DB, as it now has an official home on www.iana.org. Task-number: QTBUG-99747 Pick-to: 6.3 6.2 Change-Id: I9af67426d15609dfaf5f335405ceb1218fcf40ff Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Avoid overflow in some more qdatetime.cpp functionsEdward Welbourne2022-03-251-28/+36
| | | | | | | | | | | | | | | | | One multiplied TIME_T_MAX * MSECS_PER_SEC despite knowing this to be too close for comfort to the bounds of qint64; but the comment indicated it should have been using a 32-bit signed max in place of TIME_T_MAX. Two others simply neglected to check for overflow. Also use QRoundingDown::qMod() in one place to avoid needlessly complicating arithmetic; and assert, in another, that we were never in danger of overflowing anyway (thanks to an earlier isValid() check). Restructured QDateTimePrivate::zoneMSecsToEpochMSecs() in the process of catching its potential overflow. Change-Id: I429321d90246ba922cccf09a4f028f03a514cb6b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QDateTime: enable larger ShortData for bootstrapped buildMarc Mutz2022-03-232-2/+2
| | | | | | | | Ensures we get a modicum of testing of the Qt7 32-bit code in. Change-Id: I0838e4340265e19ab2b17a1a91a11ef5f9948893 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Core: Do not depend on transitive includesFabian Kosmale2022-03-172-0/+2
| | | | | Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17 Reviewed-by: Marc Mutz <marc.mutz@qt.io>