summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qtimezoneprivate_mac.mm
Commit message (Collapse)AuthorAgeFilesLines
* Don't lose precision in QMacTimeZonePrivate::previousTransition()Edward Welbourne2017-10-161-1/+1
| | | | | | | | | | | | | | | NSTimeInterval is a typedef for double, but the code stored its value in an int, and only then multiplied by 1000. Fix by only truncating NSTimeIntervals to int(64_t) *after* the multiplication by 1e3 to get milliseconds. While it's highly unlikely that a transition will have fractional seconds length, don't assume if you can just calculate the more exact result. Adapted-From: Marc Mutz <marc.mutz@kdab.com> Change-Id: I0911b9c945a94ca24c3dfb23ed6a849141076326 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* Fix QMacTimeZonePrivate::previousTransition() for early after epochEdward Welbourne2017-07-201-18/+70
| | | | | | | | | | | | | | | | | | | | | | | | | The native APIs don't support previous transition, only next after a stipulated date. The prior code started its search at the epoch; if used for a time before the first transition after the epoch, this found no transitions so returned invalid data, when the last transition before the epoch would have been suitable. It also wound through all transitions since the epoch, on its way to the selected time, which was potentially laborious. Instead, start a year before the stipulated time; this should get a transition if the zone uses DST. If it doesn't, start with the first known transition and binary-chop our way to one within a year of the last before the stipulated time; then wind forward one transition at a time, as before. The chopping is actually faster than binary: each time we find a transition after the interval mid-point but early enough, we move the early end of our interval to the transition, which is later than the old interval's middle. Using halving, starting with a vast interval, should thus only incur modest cost, while ensuring we give up early when no transition data is available at all or the zone's first transition ever was after the stipulated time. Change-Id: I96c14540fc2600837e6a22e480fb8dc36cb37220 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* Add conversion functions for QTimeZone and CFTimeZone/NSTimeZoneJake Petroules2017-01-231-0/+5
| | | | | Change-Id: I3a2e18d69577296bf612e13e40414bce1daa6a71 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QCFString::to(CF/NS/Q)String usage with QString methodsTor Arne Vestbø2016-10-061-10/+10
| | | | | | | | Slims down QCFString and leaves only one implementation of converting back and forth between CF/NS strings and QStrings. Change-Id: I068568ffa25e6f4f6d6c99dcf47078b7a8e70e10 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Edward Welbourne2016-07-151-0/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/library/qmakeevaluator.cpp One side changed the iterator to use ranged-for, the other changed its body; they only conflicted because the latter had to add braces around the body, intruding on the for-line. Trivial resolution. Change-Id: Ib487bc3bd6e3c5225db15f94b9a8f6caaa33456b
| * QMacTimeZonePrivate - correctly initialize m_nstz data-memberTimur Pocheptsov2016-07-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default ctor never initializes m_nstz but calls init with [NSTimeZone systemTimeZone].name. Init (re)sets m_nstz _only_ if this ianaId is in [NSTimeZone knownTimeZoneName], which is not guaranteed (a good example is "US/Pacific" that can be returned by systemTimeZoneId() - the similar problem is described in [*]. Set m_nstz to nil in ctor, so if 'init' fails we still have a valid (nil) pointer. [*] http://stackoverflow.com/questions/19819268/convert-ios-localtimezone-to-a-knowntimezone. Task-number: QTBUG-54330 Change-Id: I68917926350aad3158d44a06f06721f25b3fdb74 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | QDateTime: use the more efficient currentMSecsSinceEpoch()Thiago Macieira2016-07-021-1/+1
| | | | | | | | | | | | | | ... instead of creating a QDateTime object. Change-Id: Ib57b52598e2f452985e9fffd145a36911de4fa9a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | CoreLib: use const (and const APIs) moreAnton Kudryavtsev2016-04-181-1/+1
| | | | | | | | | | | | | | | | | | | | For CoW types const methods will be called. Mark store_persistent_indexes() as const, because this method does not modify the object. Change-Id: Ic867913b4fb5aaebfbaaffe1d3be45cf7b646403 Reviewed-by: Thiago Macieira <thiago.macieira@intel.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>
* QTimeZone: don't use QSet, use sorted QListMarc Mutz2015-02-171-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-21/+13
| | | | | | | | | | | | | | | | | | 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>
* Fix more double release in QTimeZone on MacJean-Philippe Proulx2014-05-021-6/+0
| | | | | | | | | | | Several objects are released without being retained. This causes double free crash. Task-number: QTBUG-37582 Task-number: QTBUG-35890 Change-Id: Ic64419c22ab555ba77ada1864feaff247798d3ad Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* Fix double release in QTimeZone on MacJean-Philippe Proulx2014-04-281-1/+1
| | | | | | | | | | | | | m_nstz is released in the destructor but not retained when using the QTimeZone(QByteArray) constructor. Task-number: QTBUG-35890 Task-number: QTBUG-37582 Change-Id: Ia569830bcd3c2f2cea04ad6696e681c4f2a3c137 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com> Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Fix double release in QTimeZone on MacFrederik Gladhorn2014-03-191-1/+0
| | | | | | | | | availableTimeZoneIds would release the enumerator. This leads to a double free, so simply don't release the enumerator. Task-number: QTBUG-37582 Change-Id: I521a9555d32545afd47095235ccee75a4f3e1974 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* QTimeZone - Change from Olson ID to IANA IDJohn Layt2014-01-111-6/+6
| | | | | | | | 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 Mac TransistionsJohn Layt2013-11-091-19/+38
| | | | | | | | Fix nextTransitions() where there are no next transitions and improve performance of previousTransition() and data(). Change-Id: I5d44525554243d139ba8d5f86e41bdfc0f7bfc25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Add Mac backendJohn Layt2013-09-231-0/+260
Add Mac backend support Change-Id: Iafa2dbd925e18431f571e3eac62983015f8bc977 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>