From 3befc55e4e7d8f46f01af13f8dd58795fffcda38 Mon Sep 17 00:00:00 2001 From: Diogo Date: Sat, 21 Sep 2024 22:43:03 +0100 Subject: [PATCH] add year formatting --- .../chat/simplex/common/model/ChatModel.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt index 53c25a9f58..7234209577 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/model/ChatModel.kt @@ -2443,13 +2443,20 @@ fun getTimestampText(t: Instant, shortFormat: Boolean = false): String { if (recent || shortFormat) { DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT) } else { + val dayMonthFormat = when (Locale.getDefault().country) { + "US" -> "M/dd" + "DE" -> "dd.MM" + "RU" -> "dd.MM" + else -> "dd/MM" + } + val dayMonthYearFormat = when (Locale.getDefault().country) { + "US" -> "M/dd/yy" + "DE" -> "dd.MM.yy" + "RU" -> "dd.MM.yy" + else -> "dd/MM/yy" + } DateTimeFormatter.ofPattern( - when (Locale.getDefault().country) { - "US" -> "M/dd" - "DE" -> "dd.MM" - "RU" -> "dd.MM" - else -> "dd/MM" - } + if (now.year == time.year) dayMonthFormat else dayMonthYearFormat ) // DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) }