diff --git a/plugins/main/src/main/java/info/nightscout/plugins/iob/iobCobCalculator/data/AutosensDataStoreObject.kt b/plugins/main/src/main/java/info/nightscout/plugins/iob/iobCobCalculator/data/AutosensDataStoreObject.kt index 1843492345..3718cb934f 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/iob/iobCobCalculator/data/AutosensDataStoreObject.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/iob/iobCobCalculator/data/AutosensDataStoreObject.kt @@ -152,9 +152,11 @@ class AutosensDataStoreObject : AutosensDataStore { } var diff = abs(someTime - referenceTime) diff %= T.mins(5).msecs() - if (diff > T.mins(2).plus(T.secs(30)).msecs()) diff -= T.mins(5).msecs() - diff = abs(diff) - return someTime + diff + if (diff > T.mins(2).plus(T.secs(30)).msecs()){ + return someTime + abs(diff - T.mins(5).msecs()) // Adjust to the future + } else { + return someTime - diff // adjust to the past + } } fun isAbout5minData(aapsLogger: AAPSLogger): Boolean {