Deal with daylight savings time in battery chart.
Without daylight saving time the middle between two beginnings of days can only be another beginning of a day or noon. Due to daylight savings time this can be shifted by up to one hour in either direction. This change corrects the middle value. Testing Done: Tried the calculation of the three values with Lisbon time and mStartWallTime = 1414254027000L; mEndWallTime = 1414473627000L; which spans over 10/26/2014, the day daylight saving ended in Lisbon. Change-Id: I2d2ba6e1fd2e409ca3f6b0f7674ec250da7ffad5
This commit is contained in:
@@ -1118,8 +1118,13 @@ public class BatteryHistoryChart extends View {
|
||||
if (startRoundTime < endRoundTime) {
|
||||
addDateLabel(calStart, mLevelLeft, mLevelRight, isDayFirst);
|
||||
Calendar calMid = Calendar.getInstance();
|
||||
calMid.setTimeInMillis(startRoundTime + ((endRoundTime - startRoundTime) / 2));
|
||||
|
||||
// The middle between two beginnings of days can be anywhere between -1 to 13
|
||||
// after the beginning of the "median" day.
|
||||
calMid.setTimeInMillis(startRoundTime + ((endRoundTime - startRoundTime) / 2)
|
||||
+ 2 * 60 * 60 * 1000);
|
||||
calMid.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calMid.set(Calendar.MINUTE, 0);
|
||||
long calMidMillis = calMid.getTimeInMillis();
|
||||
if (calMidMillis > startRoundTime && calMidMillis < endRoundTime) {
|
||||
addDateLabel(calMid, mLevelLeft, mLevelRight, isDayFirst);
|
||||
|
Reference in New Issue
Block a user