DateUtils: make duration rounded up to minutes

This commit is contained in:
2026-03-05 23:32:16 +01:00
parent c58c68b78a
commit 10efec4733

View File

@@ -9,10 +9,14 @@ import java.util.Date
class DateUtils {
companion object {
/**
* Format time duration in seconds as e.g. "2 hours, 1 min".
* Format time duration in seconds as e.g. "2 hours, 1 min", rounded up to minutes.
* Used for the duration to the next/previous event in the event details dialog.
*/
fun formatTimeDuration(context: Context, secondsDiff: Long): String {
return formatTimeDurationExact(context, 60L + secondsDiff - (secondsDiff % 60L))
}
fun formatTimeDurationExact(context: Context, secondsDiff: Long): String {
var seconds = secondsDiff
val years = (seconds / (365 * 24 * 60 * 60F)).toLong()