From a8a5db401fb10080cdc63fa48e4721798d328cae Mon Sep 17 00:00:00 2001
From: mkieledunsche <83220538+mkieledunsche@users.noreply.github.com>
Date: Fri, 6 Jun 2025 15:09:56 +0200
Subject: [PATCH] Improved timer finish time display in Timer.vue: adding "+Xd"
suffix to hh:mm for future days
as discussed in #382
---
vue3/src/components/display/Timer.vue | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/vue3/src/components/display/Timer.vue b/vue3/src/components/display/Timer.vue
index 491887ea6..812873dfe 100644
--- a/vue3/src/components/display/Timer.vue
+++ b/vue3/src/components/display/Timer.vue
@@ -2,7 +2,7 @@
{{ Duration.fromMillis(durationSeconds * 1000).toFormat('hh:mm:ss') }}
- {{$t('FinishedAt')}} {{ DateTime.now().plus({'seconds': durationSeconds}).toLocaleString(DateTime.TIME_SIMPLE) }}
+ {{$t('FinishedAt')}} {{ formatFinishTime(durationSeconds) }}
1
@@ -76,8 +76,25 @@ function stopTimer() {
emit('stop')
}
+/**
+* formats a future time based on a duration in seconds from now
+* displays the time in "hh:mm" format and adds a "+Xd" suffix if the target day differs from today
+*/
+function formatFinishTime(durationSeconds: number): string {
+ const now = DateTime.now()
+ const target = now.plus({ seconds: durationSeconds })
+ let timeString = target.toLocaleString(DateTime.TIME_SIMPLE)
+ const daysDifference = Math.floor(
+ target.startOf('day').diff(now.startOf('day'), 'days').days
+ )
+ if (daysDifference >= 1) {
+ timeString += ` +${daysDifference}d`
+ }
+ return timeString
+}
+
\ No newline at end of file
+