summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-10-13 18:10:39 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2017-10-16 16:11:19 +0000
commita090076e93487f8e461d9b866b9da1c0c21cb59b (patch)
tree3719fc77f5e3bb3e6e1434ede80062758c98ff44
parent414c058ca70f8e2d0a43686aa1644534a628b3ef (diff)
Don't lose precision in QMacTimeZonePrivate::previousTransition()
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>
-rw-r--r--src/corelib/tools/qtimezoneprivate_mac.mm2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm
index 876dc2d877..fa0dd87cfc 100644
--- a/src/corelib/tools/qtimezoneprivate_mac.mm
+++ b/src/corelib/tools/qtimezoneprivate_mac.mm
@@ -295,7 +295,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSec
break;
}
if (prevSecs < endSecs) // i.e. we did make it into that while loop
- return data(qint64(prevSecs) * 1000);
+ return data(qint64(prevSecs * 1e3));
// No transition data; or first transition later than requested time.
return invalidData();