From 36ff5d3bc8097e8a9aed7208303355ce95970ade Mon Sep 17 00:00:00 2001
From: BMItter <Berndus@gmx.de>
Date: Wed, 21 Apr 2021 17:26:39 +0200
Subject: [PATCH] Checkin - overnight check ins without date on the second day
 (EXPOSUREAPP-6453) (#2890)

Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com>
---
 .../checkins/common/CompletedCheckIn.kt       | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/attendee/checkins/common/CompletedCheckIn.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/attendee/checkins/common/CompletedCheckIn.kt
index e5679346f..f1fcbae59 100644
--- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/attendee/checkins/common/CompletedCheckIn.kt
+++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/presencetracing/attendee/checkins/common/CompletedCheckIn.kt
@@ -9,8 +9,19 @@ inline val CheckIn.checkoutInfo: String
         val checkInStartUserTZ = checkInStart.toUserTimeZone()
         val checkInEndUserTZ = checkInEnd.toUserTimeZone()
 
-        val dayFormatted = checkInStartUserTZ.toLocalDate().toString(DateTimeFormat.mediumDate())
-        val startTimeFormatted = checkInStartUserTZ.toLocalTime().toString(DateTimeFormat.shortTime())
-        val endTimeFormatted = checkInEndUserTZ.toLocalTime().toString(DateTimeFormat.shortTime())
-        return "$dayFormatted, $startTimeFormatted - $endTimeFormatted"
+        return if (checkInStartUserTZ.toLocalDate() == checkInEndUserTZ.toLocalDate()) {
+            val dateFormat = DateTimeFormat.shortDate()
+            val timeFormat = DateTimeFormat.shortTime()
+            val dayFormatted = checkInStartUserTZ.toString(dateFormat)
+            val startTimeFormatted = checkInStartUserTZ.toString(timeFormat)
+            val endTimeFormatted = checkInEndUserTZ.toString(timeFormat)
+
+            String.format("%s, %s - %s", dayFormatted, startTimeFormatted, endTimeFormatted)
+        } else {
+            val dateTimeFormat = DateTimeFormat.shortDateTime()
+            val startTimeFormatted = checkInStartUserTZ.toString(dateTimeFormat)
+            val endTimeFormatted = checkInEndUserTZ.toString(dateTimeFormat)
+
+            String.format("%s - %s", startTimeFormatted, endTimeFormatted)
+        }
     }
-- 
GitLab