Merge pull request #1167 from triplem/date_util

Do calculations in a central place
This commit is contained in:
Milos Kozak 2018-07-01 22:43:49 +02:00 committed by GitHub
commit 98dedf117f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -119,6 +119,7 @@ import info.nightscout.utils.OKDialog;
import info.nightscout.utils.Profiler;
import info.nightscout.utils.SP;
import info.nightscout.utils.SingleClickButton;
import info.nightscout.utils.T;
import info.nightscout.utils.ToastUtils;
import static info.nightscout.utils.DateUtil.now;
@ -839,7 +840,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (wizard.superBolus) {
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
@ -1426,12 +1427,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
predHours = Math.max(0, predHours);
hoursToFetch = rangeToDisplay - predHours;
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
endTime = toTime + predHours * 60 * 60 * 1000L;
fromTime = toTime - T.hours(hoursToFetch).msecs();
endTime = toTime + T.hours(predHours).msecs();
} else {
hoursToFetch = rangeToDisplay;
toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
fromTime = toTime - T.hours(hoursToFetch).msecs();
endTime = toTime;
}

View file

@ -179,5 +179,4 @@ public class DateUtil {
public static long roundDateToSec(long date) {
return date - date % 1000;
}
}