diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index 5e9848d814..2cb57bcf15 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -23,6 +23,7 @@ import io.reactivex.Single import java.io.Serializable import java.time.Duration import java.time.Instant +import java.time.LocalDateTime import java.time.ZonedDateTime import java.util.* import javax.inject.Inject @@ -192,7 +193,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( val minutesSinceActivation = podState.minutesSinceActivation val activationTime = podState.activationTime if ((activationTime != null) && (minutesSinceActivation != null)) { - return ZonedDateTime.from(Instant.ofEpochMilli(activationTime)) + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(activationTime), timeZone.toZoneId()) .plusMinutes(minutesSinceActivation.toLong()) .plus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem)) } @@ -208,10 +209,12 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( // TODO: Consider storing expiry datetime in pod state saving continuously recalculating to the same value get() { val podLifeInHours = podLifeInHours - val activationTime = podState.activationTime - if (podLifeInHours != null && activationTime != null) { - return return ZonedDateTime.from(Instant.ofEpochMilli(activationTime)) + val minutesSinceActivation = podState.minutesSinceActivation + if (podLifeInHours != null && minutesSinceActivation != null) { + return ZonedDateTime.now() .plusHours(podLifeInHours.toLong()) + .minusMinutes(minutesSinceActivation.toLong()) + .plus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem)) } return null } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt index a834835865..a7a3f7a302 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/OmnipodDashOverviewFragment.kt @@ -271,7 +271,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { podInfoBinding.timeOnPod.text = podStateManager.time?.let { resourceHelper.gs( R.string.omnipod_common_time_with_timezone, - dateUtil.dateAndTimeString(it.toEpochSecond()), + dateUtil.dateAndTimeString(it.toEpochSecond()*1000), podStateManager.timeZone.getDisplayName(true, TimeZone.SHORT) ) } ?: PLACEHOLDER @@ -292,7 +292,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() { // Update Pod expiry time val expiresAt = podStateManager.expiry podInfoBinding.podExpiryDate.text = expiresAt?.let { - dateUtil.dateAndTimeString(it.toEpochSecond()) + dateUtil.dateAndTimeString(it.toEpochSecond()*1000) } ?: PLACEHOLDER podInfoBinding.podExpiryDate.setTextColor(