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>
This commit is contained in:
parent
414c058ca7
commit
a090076e93
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user