summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qtimezoneprivate_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Windows code: Fix clang-tidy warnings about else after jumpsFriedemann Kleint2018-09-021-3/+3
| | | | | | | | | Replace by switch() where appropriate, remove else and unindent code or simplify the return value. Change-Id: Ie988b9068a9579ae5a899b3765e43aad480b564e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Windows code: Fix clang-tidy warnings about C-style castsFriedemann Kleint2018-08-301-9/+9
| | | | | | | | | | | Replace by reinterpret_cast or const_cast, respectively. Use auto when initializing a variable to fix Clang warnings about repeating the type name, do minor tidying along the way, and a few conversions of 0 or NULL to nullptr. Change-Id: Ieb271a87ddcf064f536e1ff05d23b1e688b1b56a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prefer ICU over system info on MS-WinEdward Welbourne2018-02-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The ICU data is more complete; and its APIs allow it to tell the whole story, which MS-Win's APIs can't (e.g. Morocco's otherwise-normal DST has a hole in it for Ramadan; when this makes four transitions in a year, the MS-APIs can't report more than two, so ignore the Ramadan gap); and their design obliges us to use heuristics to kludge round mis-description of simple changes to standard time in non-DST zones, which can't be distinguished from certain (more) obscure cases of changes to DST coinciding with a change to standard offset (causing a DST transition to hide, leaving its other end *looking like* a non-DST change to standard offset). Using ICU, when available, reduces how many end users shall be mislead by such kludges. [ChangeLog][Windows][QTimeZone] Changed MS-Win to use ICU for time-zone data, when available, in preference to MS's TZ APIs. The choice is made when building Qt. This will give reliable results when non-DST transitions arise, or when a zone's DST is not simple (e.g. interrupted by Ramadan). Task-number: QTBUG-42021 Change-Id: I9cdd65713ecdaf8cce52dd924fbc7371630977c8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clean up in TZP-Win's calculateTransitionLocalDate()Edward Welbourne2017-11-301-19/+28
| | | | | | | | | | | | | | It's decoding a SYSTEMTIME in the slightly quirky manner of MS's timezone APIs (year 0 means annual, with wDay as 1 through 4 for the first through fourth, or 5 for the last, of a specified week-day within a month) and the calculations to go with it were a little opaque. So clean it up, document what it's doing (and why) and assert some things that should be true. Also, only copy one int, instead of a whole structure, to change from their day-numbering to ours. Expand on a related TODO comment in its caller, at the same time. Change-Id: Iffd95c094c37fc1081b73b2a267cfdcd29aeb4ae Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pull several structs and static functions into an anonymous namespaceEdward Welbourne2017-11-301-22/+24
| | | | | | | | | | The implementation of QWinTimeZonePrivate used many static functions and at least one struct; to which I've added. Put these all into an anonymous namespace (thereby keeping the struct types out of the linker's sight): make them local the C++ way, rather than the C way. Change-Id: Ibdce0865234b5d4ebbdc90628cc4d9e790ed6321 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fake a "first transition" at the start of timeEdward Welbourne2017-11-301-0/+9
| | | | | | | | | | | | | | QTimeZonePrivate::dataForLocalTime() needs a transition before the time it starts at; MS's time-zone data tends to omit old zones (before 2007, in the case of Win7 for Casablanca - which had interesting transitions before that), so all we can do is extrapolate backwards from there; but a first rule is indeed apt to be a no-transition rule, describing the zone's status up to the first known transition. So fake a "start of time" transition to return for this case, that describes this prefix of history. Change-Id: Iaf178cbebc3b1e599cbde3437a0af75d9f6ca432 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Take account of single-transition hacks in MS time-zone APIsEdward Welbourne2017-11-301-16/+105
| | | | | | | | | | | | When a year contains a real change of standard time without any DST, MS's APIs still claim to have both a DST start and a DST end; one of them is bogus and positioned on the start (or end) of the year, producing no change in offset from the end of the previous (or into the start of the next) year. So code round that. Task-number: QTBUG-42021 Change-Id: Ieb6161cfb77db8a57dc181097f117316f9d1c13c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QWinTimeZonePrivate: make transition searches more efficientEdward Welbourne2017-11-301-125/+83
| | | | | | | | | | Iterate rules (now that there's fewer of them than years) with only a secondary iteration on years (when needed - in which case it should never need more than two iterations). In particular, avoid iterating years to the MIN_YEAR and MAX_YEAR extremes on failure; fail faster ! Change-Id: I354af8e0cb1e484c8abda279991e6e1824f9f7d4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refine handling of wMonth checks in QWinTimeZonePrivateEdward Welbourne2017-11-301-6/+28
| | | | | | | | | | | | | | | | | The MS API documents that the two TIME_ZONE_INFORMATION date fields either both have wMonth clear (when there is no DST) or both have it set (for each part of a DST pair). This rule is followed even when there's a standard time change without DST, with perverse results I'll deal with in a later commit. Add code in init() to verify the rule is followed and qWarning() if not. A year with no transitions doesn't imply no earlier or later year has transitions, so don't give up on searches for transitions because of it. Also fix a potential uninitialized variable bug, related to data() breaking out of a loop on such a year. Change-Id: I1ad86c07e54b2eb835a2e02d18dc64022f52a0d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid duplicate rules in QWinTimeZonePrivate::init()Edward Welbourne2017-11-151-2/+22
| | | | | | | | | | | | It was iterating the full range of years, adding a rule for each year. The rules have a startYear member and are used for later years until the next rule's startYear, so we don't need to duplicate them; and the system APIs we get them from do support recurrent rules (with wYear set to 0), that apply to ranges of years. So propagate that recurrence and reuse rules where we can. Change-Id: Ifdd292d3f3d3e07969d7a02bb01f2a0110d32950 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Restructure Dynamic TZ query to same form as Registry variantEdward Welbourne2017-11-151-17/+39
| | | | | | | | | | | | Break out the reading of an individual rule to a function and add a fall-back that tries to get a non-dynamic rule when there's no dynamic data for the zone. At the same time, change the first rule, in all cases to apply for all time (i.e. set its .startYear to MIN_YEAR, instead of 1970 or the advertised start range): we'll use it when extrapolating backwards into the past. Change-Id: Ife548c7c7deebef2427d2838f3e12ed7abb631c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace ruleForYear() method with a local index-based functionEdward Welbourne2017-11-151-15/+35
| | | | | | | | | | | Removed private method of QWinTimeZonePrivate in favor of a local static that returns a rule index rather than a rule; this prepares the way for smarter searching in transition-finding methods. In the process, re-work the function to use binary chop instead of a linear search through a potentially long sorted list. Change-Id: I2171e3f01afa3037b9718e1be7d0c9343aa74ff0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* DRY: eliminate code duplication in calculateTransitionsForYear()Edward Welbourne2017-11-151-49/+50
| | | | | | | | | | Replace with calculateTransitionForYear(), which just does one of the transitions, and wrap that with a pair-struct type to call it for DST and standard time, respectively. This also eliminate in/out arguments, which is said to be good for optimisers. Change-Id: I1e397404a0abceee7654524902af5be4eb88a625 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove some unnecessary namespace prefixingEdward Welbourne2017-11-061-1/+1
| | | | | | | | QWinTimeZonePrivate is based on QTimeZonePrivate, so can reference its members without prefix. Change-Id: I7b6bc33f70c4a497ec0caf897d48886a21f8fd65 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-04-041-1/+1
|\ | | | | | | | | | | | | | | Conflicts: src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h src/plugins/platforms/xcb/qxcbwindow.cpp Change-Id: Ic747c3c50e68c005b425e7a1ec2a90965527c8bd
| * Prefer rvalue versions of toLatin() and toUtf8()Anton Kudryavtsev2017-03-301-1/+1
| | | | | | | | | | | | | | ... to re-use existing buffers. Change-Id: I7c42529b8cd4400520a59e658ab76f4f8e965cd4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Make QLocalePrivate::codeTo*() take QStringViewsMarc Mutz2017-03-261-1/+1
|/ | | | | | | | | | ... and remove now-superfluous overloads. Adapt the sole user of the (QChar*, int) overload to construct a QStringView first, which removes the ugly cast at the call site. Change-Id: Ie5249d4b1b82d471896548e8a7d83c130ae28130 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QTimeZonePrivate: make clone() const, use covariant return typesMarc Mutz2017-02-231-1/+1
| | | | | | | | | | | | There's nothing wrong with cloning a const QTimeZonePrivate, so make clone() const. Also, if you're cloning a QTzTimeZonePrivate, you already know that you get a QTzTimeZonePrivate back. C++ supports covariant return types for this reason, so use them. Change-Id: I60e19e89b1b7bad080c552f1baca314ab0a6295e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-04-051-1/+1
|\ | | | | | | | | | | | | | | | | Conflicts: examples/corelib/ipc/ipc.pro src/plugins/platforms/xcb/qxcbbackingstore.cpp tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp Change-Id: Ia006e10ff1732fe78f90138c41f05b59b49486cf
| * QTimeZonePrivate: avoid unnecessary allocationsAnton Kudryavtsev2016-03-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | ... by replacing QString::split() with QString::splitRef() and using the new overloaded functions: - QLocalePrivate::languageToCode(QStringRef) - QLocalePrivate::languageToCode(const QChar*, int) Change-Id: I2884bdc6d3e27963ce121d659a5e092b10b4ef8c Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | QtCore: Remove Windows CE.Friedemann Kleint2016-03-301-6/+0
|/ | | | | | | | | 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>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-211-1/+99
|\ | | | | | | | | | | | | | | | | Conflicts: src/widgets/styles/qgtkstyle_p.cpp tests/auto/corelib/io/qtextstream/test/test.pro tests/auto/corelib/plugin/plugin.pro Change-Id: I512bc1b36acf3933ed2b96c00f476ee3819c1f4b
| * WinRT: Fix QTimeZone transitions by switching backendMaurice Kalinowski2016-03-161-1/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously WinRT was using the UTC backend which fails on all platforms for some QDateTime autotests related to timezone items. Hence switch to the Windows implementation for WinRT as well. However, the windows backend does query the registry heavily, which is not supported on WinRT. Instead use the API version provided by the SDK. Long-term we might want to switch to this version on desktop windows as well, as direct registry access would not be required and we could harmonize the codepaths for both platforms. Change-Id: I620b614e9994aa77b531e5c34c9be1da7e272a30 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
* | QtCore: replace QStringLiteral with QLatin1String when appendingMarc Mutz2016-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It makes little sense to use QStringLiteral for strings which are immediately appended to, or which are appended to other strings, because no dynamic memory allocation is saved by doing so. But if the only advantage of QStringLiteral does not apply, all its disadvantages dominate, to wit: injection of calls to qstring dtor, non-sharability of data between C strings and QStringLiterals and among QStringLiterals, and doubled storage requirements. Fix by replacing QStringLiteral with QLatin1String. Saves 1156B in text size on stripped optimized Linux AMD64 GCC 4.9 builds. Change-Id: If805e431f570ec1d2ac62c548f516f1b17390c3a Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Updated license headersJani Heikkinen2016-01-151-13/+19
| | | | | | | | | | | | | | | | | | | | | | 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>
* | QtCore: eradicate all Q_FOREACH loops [tools]Marc Mutz2016-01-041-4/+5
| | | | | | | | | | | | | | | | Saves just under 5.5KiB in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I6d868a7d2e469cf0564127b0e66cd7b272a0c9cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QTimeZone: replace a Q_FOREACH loop with QList::op+=Marc Mutz2015-12-311-2/+1
|/ | | | | Change-Id: I6d2cede8126346f7cd4425dafc07c794c2a7bc1d Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QTimeZone: don't use QSet, use sorted QListMarc Mutz2015-02-171-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QSet, as a node-based container, requires one memory allocation per element inserted. QList, as a contiguous-memory container (at least in the case of a QByteArray payload), requires one memory allocation per container. The higher lookup speed might still speak for using QSet, but there are only two uses of the sets: 1. Checking for existence (or lack thereof) of timezone names. For this, first generating a container full of data just to check for existence of one item of data is extremely wasteful. The QTZPrivate API should be extended to allow said lookup to be performed on the native data store instead. That leaves 2. Returning a sorted(!) list(!) from the public QTimeZone API. There is no reason why, during the construction of those sorted lists, the data should be held in a set. Instead, the well-known technique of first cramming everything into a result container, which is subsequently sorted and has its duplicates removed, can be used here. Saves more than 8K of text size on AMD64 stripped release builds. Change-Id: I71c2298e94e02d55b0c9fb6f7ebeaed79a1fe2db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright headersJani Heikkinen2015-02-111-6/+6
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Reduce QtCoreLib size by not repeating "UTC" string too often.Jędrzej Nowacki2014-07-251-2/+2
| | | | | | | | It is a minor reduction, in release build it is ~200 bytes Change-Id: I4f7972c95769f2e0ca1ddc935ff7a0a6b4379e2a Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QTimeZone - Change from Olson ID to IANA IDJohn Layt2014-01-111-14/+14
| | | | | | | | Complete changes from using Olsen/Olson in the code to IANA. Completes a change started in 5.2 release branch on the public occurrences. Change-Id: Ib077fcda2c77eef6f04ec28901d8d2d7210b8c72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Fix Windows Transitions with null rulesunknown2013-11-211-1/+10
| | | | | | | | | | Fix the Windows handling of null DST rules for a given year, if the calculation rules have a null value then can skip trying to loop through the calculations until the min/max year is hit which causes the stress test to time-out in CI, and instead return a value immediately. Change-Id: Ie2d4ee55c5487e040e0cead91d1be2a0c06d3074 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Change Olsen ID to IANA IDJohn Layt2013-11-211-4/+4
| | | | | | | | | | | | | | | The name Olson was misspelled as Olsen in the public api of QTimeZone which is needed to be fixed before first public release in 5.2 would freeze the api and prevent it being fixed. It has been decided that renaming as IANA ID would be more future-proof. Fixes to the private code will be done separately to keep this patch against release branch to the minimum required. Task-number: QTBUG-34735 Change-Id: I8ee90644862c907f6d1937b8536f0c02583ae736 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QTimeZone - Fix Windows Transitionsunknown2013-11-091-63/+89
| | | | | | | | | | The Windows tz transition routines were not checking for a number of invalid scenarios, in particular where there are no next transitions able to be calcualted, leading to infinite loops. Change-Id: I262b4321a95be1df4228774ada3908f8d3ed6c1a Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove unused static function systemtimeToMsecs()Kai Koehne2013-10-281-8/+0
| | | | | | | See also commit 660aed3516f91c that removed the reverse method. Change-Id: Ib20c5be863ba6644485c581e3ece47a390ce467d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Remove unused static function msecsToSystemtime() from qtimezoneprivate_win.cpp.Friedemann Kleint2013-10-011-11/+0
| | | | | Change-Id: I8d6b4c9215fb4499affefd0b892cea1b77aa8ac9 Reviewed-by: John Layt <jlayt@kde.org>
* QTimeZone - Add Windows backendJohn Layt2013-09-231-0/+664
Add backend implementation for Windows times zones. Change-Id: I30946f6672488c3f1d1d05754e9479aa62cce46f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>