From 80fa8d8294ee40e1ceb319f586c8986c9c9ac009 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Thu, 5 Mar 2026 23:32:16 +0100 Subject: [PATCH] DateUtils: make duration rounded up to minutes --- app/src/main/java/utils/DateUtils.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/utils/DateUtils.kt b/app/src/main/java/utils/DateUtils.kt index 14b6175..2ca3ec3 100644 --- a/app/src/main/java/utils/DateUtils.kt +++ b/app/src/main/java/utils/DateUtils.kt @@ -9,10 +9,15 @@ 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 to minutes. * Used for the duration to the next/previous event in the event details dialog. */ fun formatTimeDuration(context: Context, secondsDiff: Long): String { + val adjusted = (secondsDiff + 30) - (secondsDiff + 30) % 60 + return formatTimeDurationExact(context, adjusted) + } + + fun formatTimeDurationExact(context: Context, secondsDiff: Long): String { var seconds = secondsDiff val years = (seconds / (365 * 24 * 60 * 60F)).toLong()