Skip to content

Commit ff8c497

Browse files
committed
fix proportional duration format not showing negative goal deficit in detailed stats
1 parent 4403a60 commit ff8c497

File tree

1 file changed

+5
-3
lines changed
  • core/common/src/main/java/com/example/util/simpletimetracker/core/mapper

1 file changed

+5
-3
lines changed

core/common/src/main/java/com/example/util/simpletimetracker/core/mapper/TimeMapper.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ class TimeMapper @Inject constructor(
493493
)
494494

495495
if (useProportionalMinutes) {
496-
return formatIntervalProportional(hr, min)
496+
return formatIntervalProportional(interval, hr, min)
497497
}
498498

499499
val willShowHours: Boolean
@@ -557,13 +557,15 @@ class TimeMapper @Inject constructor(
557557
}
558558
}
559559

560-
private fun formatIntervalProportional(hr: Long, min: Long): String {
560+
private fun formatIntervalProportional(interval: Long, hr: Long, min: Long): String {
561561
val hourString = resourceRepo.getString(R.string.time_hour)
562562
val minutesProportion = min / 60f
563563
val proportional = hr + minutesProportion
564564
val proportionalString = "%.2f".format(proportional)
565565

566-
return "$proportionalString$hourString"
566+
val res = "$proportionalString$hourString"
567+
568+
return if (interval < 0) "-$res" else res
567569
}
568570

569571
fun toDayDateTitle(

0 commit comments

Comments
 (0)