remove joda

This commit is contained in:
Andrei Vereha 2021-07-11 21:35:40 +02:00
parent d1f99bfb71
commit 465ae7ee8a
2 changed files with 9 additions and 6 deletions

View file

@ -23,6 +23,7 @@ import io.reactivex.Single
import java.io.Serializable import java.io.Serializable
import java.time.Duration import java.time.Duration
import java.time.Instant import java.time.Instant
import java.time.LocalDateTime
import java.time.ZonedDateTime import java.time.ZonedDateTime
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -192,7 +193,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor(
val minutesSinceActivation = podState.minutesSinceActivation val minutesSinceActivation = podState.minutesSinceActivation
val activationTime = podState.activationTime val activationTime = podState.activationTime
if ((activationTime != null) && (minutesSinceActivation != null)) { if ((activationTime != null) && (minutesSinceActivation != null)) {
return ZonedDateTime.from(Instant.ofEpochMilli(activationTime)) return ZonedDateTime.ofInstant(Instant.ofEpochMilli(activationTime), timeZone.toZoneId())
.plusMinutes(minutesSinceActivation.toLong()) .plusMinutes(minutesSinceActivation.toLong())
.plus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem)) .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 // TODO: Consider storing expiry datetime in pod state saving continuously recalculating to the same value
get() { get() {
val podLifeInHours = podLifeInHours val podLifeInHours = podLifeInHours
val activationTime = podState.activationTime val minutesSinceActivation = podState.minutesSinceActivation
if (podLifeInHours != null && activationTime != null) { if (podLifeInHours != null && minutesSinceActivation != null) {
return return ZonedDateTime.from(Instant.ofEpochMilli(activationTime)) return ZonedDateTime.now()
.plusHours(podLifeInHours.toLong()) .plusHours(podLifeInHours.toLong())
.minusMinutes(minutesSinceActivation.toLong())
.plus(Duration.ofMillis(System.currentTimeMillis() - lastUpdatedSystem))
} }
return null return null
} }

View file

@ -271,7 +271,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
podInfoBinding.timeOnPod.text = podStateManager.time?.let { podInfoBinding.timeOnPod.text = podStateManager.time?.let {
resourceHelper.gs( resourceHelper.gs(
R.string.omnipod_common_time_with_timezone, R.string.omnipod_common_time_with_timezone,
dateUtil.dateAndTimeString(it.toEpochSecond()), dateUtil.dateAndTimeString(it.toEpochSecond()*1000),
podStateManager.timeZone.getDisplayName(true, TimeZone.SHORT) podStateManager.timeZone.getDisplayName(true, TimeZone.SHORT)
) )
} ?: PLACEHOLDER } ?: PLACEHOLDER
@ -292,7 +292,7 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
// Update Pod expiry time // Update Pod expiry time
val expiresAt = podStateManager.expiry val expiresAt = podStateManager.expiry
podInfoBinding.podExpiryDate.text = expiresAt?.let { podInfoBinding.podExpiryDate.text = expiresAt?.let {
dateUtil.dateAndTimeString(it.toEpochSecond()) dateUtil.dateAndTimeString(it.toEpochSecond()*1000)
} }
?: PLACEHOLDER ?: PLACEHOLDER
podInfoBinding.podExpiryDate.setTextColor( podInfoBinding.podExpiryDate.setTextColor(