diff --git a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt index 2b7806468e..b59d4a40e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/stats/TIR.kt @@ -18,7 +18,7 @@ class TIR(val date: Long, val lowThreshold: Double, val highThreshold: Double) { fun above() = run { above++; count++ } fun belowPct() = if (count > 0) (below.toDouble() / count * 100.0).roundToInt() else 0 - fun inRangePct() = if (count > 0) (inRange.toDouble() / count * 100.0).roundToInt() else 0 + fun inRangePct() = if (count > 0) 100 - belowPct() - abovePct() else 0 fun abovePct() = if (count > 0) (above.toDouble() / count * 100.0).roundToInt() else 0 fun toText(resourceHelper: ResourceHelper, dateUtil: DateUtil): String = resourceHelper.gs(R.string.tirformat, dateUtil.dateStringShort(date), belowPct(), inRangePct(), abovePct())