Skip to content

Commit

Permalink
Merge pull request #83 from cubandle/stopped_milestones
Browse files Browse the repository at this point in the history
Hide milestone progress on stopped addictions
  • Loading branch information
KiARC authored Jan 15, 2023
2 parents 3660f70 + f2ba689 commit 69ad0e5
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ data class Addiction(
*/
fun calculateMilestoneProgressionPercentage(milestone: Pair<Int, DateTimeUnit>): Pair<Long, Int> {
val goal = lastRelapse.toEpochMilliseconds() + milestone.first * milestone.second.toMillis()
if (isStopped) {
return Pair(goal, 0)
}
return Pair(goal, (((Clock.System.now().toEpochMilliseconds() - lastRelapse.toEpochMilliseconds()).toFloat() /
(goal - lastRelapse.toEpochMilliseconds())) * 100).toInt())
}
Expand Down

0 comments on commit 69ad0e5

Please sign in to comment.