summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
Commit message (Collapse)AuthorAgeFilesLines
* QtCore: includemocsMarc Mutz2022-01-271-0/+4
| | | | | | | | | | | | | | | This leaves moc_qnamespace.cpp in mocs_compilation.cpp. Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Change-Id: Ifdff378c74828e12ec770cb2f453dab3a880e2a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QCalendar: move memory allocation out of critical sectionMarc Mutz2022-01-271-1/+2
| | | | | | | | | | | | By Amdahl's Law, provides for more scalability. This is just for backporting. The registry should really be able to perform lookups without allocating memory... Pick-to: 6.3 6.2 Change-Id: Ifbb832a06991b9ee9a1fd6a43db567bb572fca4f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify some #if-ery and use positive testsEdward Welbourne2022-01-171-8/+6
| | | | | | | | | | Two cases coincide without feature textdate, and the first falls through to the second with the feature, making it possible to simplify the #if-ery, converting its tests to positive form and skipping a duplicate case body in the process. Change-Id: I2c0ee800442474707bf8893bd72b9706fef54485 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Use \inmodule for all classes and headersTopi Reinio2022-01-171-0/+1
| | | | | | | | | | | | | | | QDoc made some assumptions about the module a class/header belongs to, based on the source file path. This feature is rather error-prone and unnecessarily complex and will be removed from QDoc. Define modules explicitly to avoid documentation warnings when this removal happens. Pick-to: 6.2 6.3 Change-Id: I7947d197db5ac36c12e816caa19bb2f74eda8849 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Fix an assertion failure in massageAdjustedDateTime()Edward Welbourne2022-01-131-4/+4
| | | | | | | | | | | | | | The QDateTimeData &d it's passed is a copy that's about to be modified; before we do so, we haven't detached so its internals have a ref-count of two, contradicting an assertion in the non-const Data::operator->(); so just directly access d.d->m_timezone, since we know that spec == TimeZone implies !isShort(). Added test that triggered the assertion and now doesn't. Fixes: QTBUG-99668 Pick-to: 6.3 6.2 6.2.3 5.15 Change-Id: I07321ad91be5adce524be18e4ab82eee7110dc6a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QTzTimeZonePrivate: fix UB (data race on m_icu)Marc Mutz2022-01-121-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | The fallback m_icu QIcuTimeZonePrivate is lazily constructed, which means that two threads each with their own copy of a QTimeZone with a shared QTzTimeZonePrivate will race over who gets to set m_icu, e.g. when concurrently calling QTimeZone::displayName(). Fix by protecting m_icu with a mutex. For simplicity, use a static mutex, not a per-instance one (which would delete the QTzTimeZonePrivate copy constructor, which clone() relies on). This is sufficient for 5.15. For Qt 6, going forward, we could make this lock-less, too. [ChangeLog][QtCore][QTimeZone] Fixed a data race on Unix platforms when implicitly-shared copies of QTimeZone objects were used in certain ways (e.g. calling displayName()) from different threads and Qt was configured with ICU support. Pick-to: 6.3 6.2 5.15 Change-Id: I7e57aef3dd44a90289ad86d0578ece1e54920730 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTzTimeZonePrivate: use ctor delegation instead of init()Marc Mutz2022-01-052-9/+9
| | | | | | | | | | | | | | This makes it obvious that the code in init() is only called from the constructor and its m_icu handling doesn't need mutex protection (to be added in a subsequent commit). Since the input to the ctor is the result of a virtual function, factor said virtual into a static function and call that instead. Pick-to: 6.3 6.2 5.15 Change-Id: I7c49f2e865201a2ce2b2d86b19dae29c6d337e0e Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTzTimeZonePrivate: fix permanently-detaching m_icuMarc Mutz2022-01-051-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | The m_icu member is a mutable QSharedDataPointer, which means that only the non-const API subset is accessible, and so any access to it will always detach, in 5.15 even a check like if (m_icu), which the code luckily doesn't use (Qt 6 added a operator bool() const). We don't need detaching behavior here, though, since, once set, m_icu is never changed. So just use a QExplicitlySharedDataPointer instead, and never call detach() (which would do the wrong thing). Just in case someone does add a detach() later, instantiate QExplicitlySharedDataPointer over QIcuTimeZonePrivate directly. This requires making displayName() overloads from QTimeZonePrivate visible in QIcuTimeZonePrivate. Add an assertion that QIcuTimeZonePrivate is final, with instructions on what to do if it fails. Finally, hold a pointer-to-const to avoid race conditions in the pointee. The code still contains a data race, due to the lazy initialization of m_icu, but now we have at least a fighting change to fix it. Pick-to: 6.3 6.2 5.15 Change-Id: I32c343822dac43f96d9fbc4c759fa44138861eae Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: fix UB (signed overflow) in addDays()Marc Mutz2021-12-211-3/+4
| | | | | | | | | | | | The comment indicated that the author expected any overflow to be caught by a bounds check in the subsequent function, however, signed overflow is UB, so anything can happen. Fix by using our API for safe additions instead. Pick-to: 6.3 6.2 5.15 Change-Id: I41909defffa5305b02fdfcf6d5808e0d9fd5924f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove some spurious prefixes in declarationsEdward Welbourne2021-11-182-4/+4
| | | | | | | | | | The parameter-list of a method is already in its class's context, so doesn't need it made explicit on the other class members involved. Change-Id: I253b098ad1f2d2db80d49d8f484b7f95d14acec1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Add a note on the sign of daylight-saving offsetsEdward Welbourne2021-11-181-1/+4
| | | | | | | | | | | Given that at least one zone has a negative offset (so that it's in standard time for most of the year, including summer, and daylight-saving time relatively briefly during winter), QTimeZone's docs should explain what that means. Change-Id: I6649b4cdefbd685dc97bf85d957960da44d07aed Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Eliminate a constant from qtimezoneprivate_win.cppEdward Welbourne2021-11-181-6/+7
| | | | | | | | | Its MIN_YEAR was duplicating what's now provided by QDateTime::YearRange::First, so use that instead. In the process, tidy up an over-long line. Change-Id: I109f5435f63cb5cc97d54529a172b640f919dec0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove some unused constants from qtimezoneprivate_win.cppEdward Welbourne2021-11-181-6/+3
| | | | | | | | | Recent commit 6845c444d082cfac561b3c8f28f53480ae066746 elicits warnings about two unused constants. Remove an unused macro at the same time, and add missing LL suffix to remaining qint64 constants. Change-Id: I4c84e10b512030e0e4f860d434382e62e6c936f5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Revise (recently-added) yearSharingWeekDays() to take a QDateEdward Welbourne2021-11-152-14/+34
| | | | | | | | | | This lets it avoid a two-digit year that would clash with month or day. That shall make fixing up system locale date formatting run cleaner. Add a test for QGregorianCalendar's two extensions. Change-Id: I77083ff9d5e4035763250904a59fcf416286545b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid overflow for date-time in the first (partly) representable dayEdward Welbourne2021-11-111-2/+10
| | | | | | | | | | | | | | Computing the start of the first day's number of milliseconds since the epoch overflows, but adding enough seconds within the day would have brought us back inside the representable range. So, for days before the epoch, add a negative number of milliseconds from the end of the next day instead of a positive number of milliseconds from the (possibly unrepresentable) start of the target day. This is another a follow-up to commit 2b26dea51b26fff2ea955ad2b50c2c20194f0103 Change-Id: I2e0c68d7012db85dfe7da4a8a20ba95368178ed1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace enum with constexpr qint64 variablesEdward Welbourne2021-11-111-7/+5
| | | | | | | It's the modern recommended way to do it. Change-Id: I10db128348014b316c1772d18396f272b0a2b766 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix 32-bit builds broken by mul_overflow() on qint64Martin Storsjö2021-11-101-1/+1
| | | | | | | | | Use std::integral_constant to avoid instantiating QIntegerForSize<16>, caused by 2b26dea51b26fff2ea955ad2b50c2c20194f0103 Change-Id: Ia6f49a1dcd82835c7e76200a650767fc519eab90 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QGregorianCalendar::yearSharingWeekDays()Edward Welbourne2021-11-102-0/+27
| | | | | | | | | | | When fixing up problems on system APIs with limited date ranges, we need a year, inside the supported date range, in which Gregorian dates fell on the same days of the week as a given year outside the range. A year with the same last two digits makes handling of two-digit year formats easier. Change-Id: If64ee27e829f9dcfd5504ed8ba51f72c36297242 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: Add support for Kaingang and Nheengatu languagesIevgenii Meshcheriakov2021-11-103-1/+30
| | | | | | | | | | Update the locale generation script to support Kaingang and Nheengatu languages. These are new in CLDR v40. Regenerate the locale data. Task-number: QTBUG-94358 Change-Id: I5195d5161d8c4d9f17129bbcfde39dfd3fcf1cd5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Update CLDR-derived data to newly-released v40Ievgenii Meshcheriakov2021-11-103-2399/+2427
| | | | | | | | | | | | | Update tst_qlocale to take into account "narrow" day representation change for Russian locales. This version of CLDR changes narrow forms to one letter. Previously those forms were identical to short forms (two letter). The new representation is consistent with other languages and so does not appear to be a bug. Fixes: QTBUG-94358 Pick-to: 6.2 Change-Id: I9724c281a250685da8232e5c05c9c375a8c79253 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* locale_database: Add entry for 'South Sudan Standard Time'Ievgenii Meshcheriakov2021-11-101-172/+174
| | | | | | | | | | | | This timezone is new in CLDR 40, Olson database calls it Africa/Juba. The offset is UTC+2. Reference: https://techcommunity.microsoft.com/t5/daylight-saving-time-time-zone/2021-time-zone-updates-for-republic-of-south-sudan-now-available/ba-p/2234981 Task-number: QTBUG-94358 Pick-to: 6.2 Change-Id: Ib70dbd9b472eb9cf8cb62a0eb5e241199148c077 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix some out-of-range issues with time-zone supportEdward Welbourne2021-11-082-12/+24
| | | | | | | | | | | | | | | The MS-Windows back-end neglected to check for overflow when mapping date and time to milliseconds from the epoch. Add the checks for that and take care not to return qint64-min as a transition time - that's the invalidMSecs() value used as a special marker. QTimeZonePrivate::dataForLocalTime() neglected to handle the case of the backend being unable to answer offsetFromUtc() for one of the times requested, which the MS backend might. Change-Id: I6d7ee2cbf9aaf6678abb24a20e18b5cdac7f5a23 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix qdoc warningsVenugopal Shivashankar2021-10-231-1/+1
| | | | | | | | | | | | | | | | | src/corelib/kernel/qmetatype.cpp:1605: (qdoc) warning: Command '\snippet (//! [[implicit]])' failed at end of file 'qmetatyp> src/corelib/kernel/qmetatype.cpp:1615: (qdoc) warning: Command '\snippet (//! [[member]])' failed at end of file 'qmetatype/> src/corelib/kernel/qmetatype.cpp:1626: (qdoc) warning: Command '\snippet (//! [[memberOk]])' failed at end of file 'qmetatyp> src/corelib/kernel/qmetatype.cpp:1639: (qdoc) warning: Command '\snippet (//! [[unaryfunc]])' failed at end of file 'qmetaty> src/corelib/text/qbytearraymatcher.cpp:233: (qdoc) warning: No such parameter 'view' in QByteArrayMatcher::indexIn() src/corelib/time/qdatetime.cpp:1854: (qdoc) warning: Can't link to 'QLocaleie:pmText()' src/corelib/thread/qsemaphore.cpp:494: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/corelib/thread/qsemaphore.cpp:505: (qdoc) warning: Undocumented parameter 'timeout' in QSemaphore::try_acquire_for() src/corelib/thread/qsemaphore.cpp:505: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text src/corelib/thread/qsemaphore.cpp:516: (qdoc) warning: Undocumented parameter 'tp' in QSemaphore::try_acquire_until() src/corelib/thread/qsemaphore.cpp:516: (qdoc) warning: Undocumented return value (hint: use 'return' or 'returns' in the text Change-Id: Ib612c69525ec7542f2ad3dd9a07e89f266718fd8 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* QDateTime: Limit string processing to known boundariesMårten Nordheim2021-10-201-6/+18
| | | | | | | | | | | We were treating the input as if it was always reasonably good. Since we know the max boundaries anyway lets just stop processing when those are reached Fixes: QTBUG-97489 Change-Id: Ibb78d6d51ad58454b2007ab46d54116ca0be5448 Reviewed-by: Robert Löhning <robert.loehning@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Convert Latin1 to UTF-16 before passing to ICU APIEdward Welbourne2021-10-141-5/+5
| | | | | | | | | | The ICU UChar type is a UTF-16 type, not a single-byte type, so passing it the data() of a QByteArray representing an ID is misguided. Fixes: QTBUG-97486 Pick-to: 6.2 6.2.1 Change-Id: I6789f491674b1d913eb8655d788b497e2fc06f7a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix handling of time-zone gap in QTimeZonePrivate::dataForLocalTime()Edward Welbourne2021-10-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This was handled correctly when the backend supplies transitions bracketing the time in question, but the fallback code tried to use the DST offset at the time with larger offset from UTC; this did not work when the gap was due to a change in standard time. Discovered by ANS1 parsing of a date-time with two-digit year, for which the date-time parser tried to use 1921-05-01T00:00 local time when filling in the fields it had parsed; but, when run in Europe/Helsinki, there is no such time due to the 20m 11s skipped when joining EET from the prior local solar mean time. Correct the calculation to use the actual change in offset from UTC, as used in the (far better tested) between-transitions branch of the code, rather than the DST offset after the transition. Add a test-case based on the ASN.1 certificate date whose parsing revealed the issue. Although it seems nothing in Coin can reproduce the issue, the reporter has verified that the test does indeed fail on the system where the bug was found and the fix does fix it. Fixes: QTBUG-96861 Pick-to: 6.2 Change-Id: I12b02bad01daca2073d1a356452cd573684aa688 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* corelib: Fix typos in documentationJonas Kvinge2021-10-122-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* corelib: Fix typos in source code commentsJonas Kvinge2021-10-124-6/+6
| | | | | | Pick-to: 6.2 Change-Id: Ic78afb67143112468c6f84677ac88f27a74b53aa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Set tm_isdst = -1 before calling mktime()Edward Welbourne2021-10-111-0/+3
| | | | | | | | | | | Leaving it set to 0 will cause mktime() to interpret other fields as in standard time, potentially "correcting" them and tm_isdst to represent the equivalent moment in daylight-saving time. Set it to -1 to tell mktime() to let the system work out whether the time is standard or daylight-saving. Change-Id: Id33d4cb0afdb14f236ca5ce04cf605610a30d712 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Broaden condition on use of MS's localtime_s()Edward Welbourne2021-10-111-2/+2
| | | | | | | | | | | | It's available on MinGW, so not limited to MSVC; and the MinGW localtime() and localtime_r() fail in some cases where it works. Use the generic name rather than _localtime64_s(), since localtime_s() now just calls it; and, in any case, we were assuming time_t is __time64_t when calling it. Change-Id: I316cc5b1a3e19cd6725555042dfaba3124a25a03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove an overly-complex assertionEdward Welbourne2021-10-041-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | It tried to sanity-check the correction being made to the time as a result of converting zone to UTC, but handling also the case where the correction avoided a gap. However, there are too many quirky cases to permit a simple condition. The latest to trip it up is a case of a zone leaving local solar mean time; a time in the gap that hits is shunted by the width of the gap, which could be any old thing, and won't show up on the data describing the zone before or after the transition. In any case, one branch of the check was doubling the zone's standard time offset, which makes no sense. As that was checking for double-DST, it would need to check standard offset plus twice the usual DST offset; but the data it's looking at probably has its DST offset set to the doubled one that needs to deal with. In general a change in DST without going via standard time will have problems here, and a change to standard time could also present problems. Stop trying to shore up the assert and just trust the offset we got. Change-Id: I4519f47e79dfb7595f4a12c259b80a338bc7033c Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: fix build with MinGW: need unistd.h very earlyThiago Macieira2021-09-291-3/+0
| | | | | | | | | | | qobject.h has #include <chrono>, which #includes <ctime>, which includes <time.h>. datetime.cpp:2621:23: error: 'localtime_r' was not declared in this scope; did you mean 'localtime_s'? Pick-to: 6.2 Change-Id: I2bbf422288924c198645fffd16a922719c4ce7d4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix QDateTimeParser's handling of 't' format to match serializationEdward Welbourne2021-09-201-1/+4
| | | | | | | | | | | | | | | | | | This amends commit 68f19fb630dc02463c2d61fc511de7407687795e to only consume one 't' from the format string, to match qlocale.cpp's serialization of time-zone specifiers, which only consumes one, so will repeat the time-zone specifier as many times as unquoted t appears in the format. It's hard to imagine why anyone would want this behavior, but it's what our serialization has always done and parsing should match serialization. Add test-cases for double time-zone specifier. Delete a lie in the process. Task-number: QTBUG-95966 Change-Id: I574896040a74085dee89a4fefd8384be44ad827b Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-173-11/+11
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Modernise and simplify handling of qtimezoneprivate_data_p.h's dataEdward Welbourne2021-09-102-120/+68
| | | | | | | | | | | | | | | | | Add some trivial inline methods to the classes that populate the tables to simplify access to their data. Use ranged-for loops to iterate those tables (now that they no longer have bogus all-zero entries at the end). In the process, noticed windowsIdToDefaultIanaId() doing a double iteration of the windowsDataTable, first via toWindowsIdKey() to map a windowsId to a key, then again to map that key to the matching ianaId; inline the former and use the table row from which it got the key to extract its ianaId instead. Change-Id: I76267f53c7e6f5c593e33b6146b8f98bfb6d042f Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Remove trailing zero rows from qtimezoneprivate_data_p.h's tablesEdward Welbourne2021-09-102-8/+4
| | | | | | | | | | They are not needed. Iterations over the table track their sizes. The size-of-table constants just needed their -1s removed. Incidentally use std::size() rather than sizeof(array)/sizeof(element). Change-Id: Ie20eef9f6f5786d93c10b830a87e006d3c5bcc1a Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add new am/pm format-specifier that preserves locale's caseEdward Welbourne2021-09-083-47/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing a, ap, A and AP specifiers all force the case of the formatted am/pm indicator. The indicators returned by QLocale's amText() and pmText() methods are those given in CLDR, with no case coercion. Application writers may reasonably want these strings used verbatim, rather than having to chose a case and impose it on the locale's indicators, in defiance of national custom. For example, while en_US uses upper-case indicators by default, cs_CZ uses lower-case ones. An application author writing a time format has been forced to chose which of these locales to be wrong in. Add support for aP and Ap specifiers, whose mixed case indicates that the locale's case is to be respected. Amend an existing test-case of tst_QLocale's formatDateTime() that used Ap (expecting, of course, an upper-case indicator followed by a stray p) to now expect the locale-appropriate-cased indicator. Extend formatTime() to test cases using aP and Ap, to illustrate the difference between en_US and cs_CZ. Rework QDateTimeParser to also support the new format specifier. This required expanding its Case enum, used by the getAmPmText() method, which was formerly shared with QDateTimeEditPrivate; however, as that class no longer makes any reference to this method, it and the enum can be made private, allowing a systematic clean-up of their use. Added test-cases for both serialization and parsing; and amended some existing parsing tests to verify am/pm indicators are matched case-insensitively. [ChangeLog][QtCore][Important Behavior Changes] Time formats used by QLocale, QTime and QDateTime's parsing and serialization now recognize 'aP' and 'Ap' format specifiers to obtain an AM/PM indicator, using the locale-appropriate case for the indicator, where previously the author of a time format had to pick a case that might conflict with the user's locale. For QTime and QDateTime the locale is always C, whose indicators are uppercase. For QLocale, the case will now match that of amText() or pmText(). Previously, 'aP' would have been read as a lower-case indicator followed by a 'P' and 'Ap' as an upper-case indicator followed by a 'p'. The 'P' or 'p' will now be treated as part of the format specifier: if the prior behavior is desired, either use 'APp' or 'apP' as format specifier or quote the 'p' or 'P' in the format. The prior 'a', 'ap', 'A' and 'AP' specifiers are otherwise unaffected. Fixes: QTBUG-95790 Change-Id: I26603f70f068e132b5c6aa63214ac8c1774ec913 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Remove a redundant checkEdward Welbourne2021-09-021-1/+1
| | | | | | | | | Missed in a recent fix to QTimeZonePrivate::dataForLocalTime(), but noticed during picking back to 5.12 Pick-to: 6.2 Change-Id: I63964952150fedf857b7aef12dfc866097d2e2d1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix corner case in QTimeZonePrivate::dataForLocalTime()Edward Welbourne2021-09-011-14/+18
| | | | | | | | | | | | | | | If the local time for which we want data is after the last known transition, the two transitions we get to bracket it are the last known and an invalid one. The code checked the former was valid, but neglected to check the latter, leading to nonsense arithmetic later in the function. In this situation we unequivocally want the last known transition, so the problem is easily solved. Fixes: QTBUG-96152 Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I6fc830ce538e8a572093cd8dfe832e10689bf904 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Convert various callers of strtou?ll() to call strntou?ll()Edward Welbourne2021-08-301-9/+3
| | | | | | | | Where size is known or can readily be determined. Change-Id: I442e7ebb3757fdbf7d021a15e19aeba533b590a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Fix documentation issues for Qt CoreTopi Reinio2021-08-241-14/+14
| | | | | | | | | | | | | | * Tag deprecated Q(Multi)Map operators in the header to correctly match them with documentation \fn commands. * Add documentation for QByteArrayView comparison operators. * Add a dummy typedef 'jfieldID' for generating docs correctly on non-Android platforms * Fix other minor issues Pick-to: 6.2 Task-number: QTBUG-95860 Change-Id: I141d2f75d6aa10557aa374201f09ad74b4cd6e81 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* wasm: fix assert in QDateTimeLorn Potter2021-08-191-1/+1
| | | | | | | like windows, we dont have historical time data Change-Id: Iab77c1e2949bc909324f18209e6c52324c80a548 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDateTime: port to QStringTokenizer and QVLAMarc Mutz2021-08-181-3/+6
| | | | | | | | | | | | | The code isn't easily linearized to work directly with QStringTokenizer, which is a forward-only range, but we can at least remove the (non-error) memory allocations by supplying a suitably-sized QVLA to tokenize into instead of the default QList. Change-Id: I1aa11a5fbbe66ede4ec2e5b2090044a39052a241 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QDateTime: port away from takeFirst() useMarc Mutz2021-08-161-6/+11
| | | | | | | | | | | | | | | | | | Use the std-compatible API subset instead. This is in preparation of using QVarLengthArray instead of QList here, which (thankfully, because it's inefficient for arbitray T) doesn't have pop_front(). As a drive-by, port at(0) to front() and introduce a temporary variable. The front() call will briefly emit a detach attempt (but the container isn't shared, so it won't actually detach), but only until the next patch ports to QVLA. Change-Id: I38ee123aa6730aee5ba1e14ec46fc71c5d74986e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QCalendarRegistry: Explicitly disable moving and copyingIevgenii Meshcheriakov2021-08-101-0/+2
| | | | | | | | | | | | | | | | | | | Add Q_DISABLE_COPY_MOVE to QCalendarRegistry to silence the following warning produced by QtStaticAnalysisBot: class 'QCalendarRegistry' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator QCalendarRegistry is a singleton so it does not need to be moved or copied. The warning was introduced by d0ae1ef33a6eed02acde7304298794f4f0119e16. Task-number: QTBUG-93004 Pick-to: 6.2 Change-Id: I5e018346415b9d0a1ebc3bbde2ab7c3ad5e6d9d0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendar: Delete registered calendar backends on program exitIevgenii Meshcheriakov2021-08-062-17/+76
| | | | | | | | | Add code to check if the calendar registry is destroyed to all QCalendar methods that dereference QCalendarBackend pointer. Pick-to: 6.2 Change-Id: I9b562355e2e0579396b52968f6065c6927cc9ca8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendar: Thread-safe calendar backend registrationIevgenii Meshcheriakov2021-08-0615-416/+499
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All calendar backend accounting was moved into QCalendarRegistry class (renamed from Registry). Calendar backends are no longer registered inside constructors, because in multithreaded environment this may lead to incompletely initialized instances becoming visible via QCalendar API in multithreaded environment. All system backends are registered by QCalendarRegistry itself when they are needed. New method QCalendarBackend::registerCustomBackend() is provided to register any 3rd-party calendar backends. Registration by names was also simplified. The list of names is now passed to QCalendarBackend::registerCustomBackend(). The checks are provided to ensure that all system backends have non-conflicting names. Name conflicts for custom backends are resolved in favor of earlier registered backends, as it is already the case in the existing code. The documentation was updated to reflect that. Method QCalendarBackend::names() was added to query the list of names associated with a backend after it is registered. Calendar backend deregistration was completely removed because it is not possible to perform it safely without reference counting. Fixes: QTBUG-93004 Pick-to: 6.2 Change-Id: I0ab1eccc02fdd1e1c66b5e5dd076c93de32d5a49 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* time: Rerun cldr2qtimezone.pyIevgenii Meshcheriakov2021-07-271-33/+33
| | | | | | | | | | | | | | This updates qtimezoneprivate_data_p.h changing any mention of Country to Territory in it. The change was introduced by the following commit: e51831260a759b58cb089cac089c202a795fc584 There are no code changes. This reduces number of changes visible after rerunning cldr2qtimezone.py. Pick-to: 6.2 Change-Id: I0898ecf224108604b7178e31fa7e76b4cb13a965 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendar: Make SystemId constructors with one argument explicitIevgenii Meshcheriakov2021-07-271-2/+3
| | | | | | | | This avoids unwanted type conversions. Pick-to: 6.2 Change-Id: Ie57e80da615c6bc162224fa3816fc21a47ab4b00 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCalendarBackend: Use QAnyStringView to create backends by nameIevgenii Meshcheriakov2021-07-273-17/+5
| | | | | | | | | | | | | | Combine two implementations of QCalendarBackend::byName() accepting QStringView and QLatin1String arguments into one accepting QAnyStringView to reduce code duplication. Add a note to QCalendar constructors accepting strings to do the same for Qt 7. Change-Id: Idfc3b9c61e22712543c723bd94fcd788da52780a Pick-to: 6.2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>