Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: ash/system/chromeos/power/power_status.cc

Issue 258303002: chromeos: Fix a bug in the battery-time-rounding code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/system/chromeos/power/power_status_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/power/power_status.cc
diff --git a/ash/system/chromeos/power/power_status.cc b/ash/system/chromeos/power/power_status.cc
index 7f418c85743f558f38da90a4200dcc77a780d822..8940e9ecb472b8b021a9e7270530541ee6f47a0c 100644
--- a/ash/system/chromeos/power/power_status.cc
+++ b/ash/system/chromeos/power/power_status.cc
@@ -117,10 +117,9 @@ void PowerStatus::SplitTimeIntoHoursAndMinutes(const base::TimeDelta& time,
int* minutes) {
DCHECK(hours);
DCHECK(minutes);
- *hours = time.InHours();
- const double seconds =
- (time - base::TimeDelta::FromHours(*hours)).InSecondsF();
- *minutes = static_cast<int>(seconds / 60.0 + 0.5);
+ const int total_minutes = static_cast<int>(time.InSecondsF() / 60 + 0.5);
+ *hours = total_minutes / 60;
+ *minutes = total_minutes % 60;
}
void PowerStatus::AddObserver(Observer* observer) {
« no previous file with comments | « no previous file | ash/system/chromeos/power/power_status_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698