From a210189137318d58afafdf0ed847b38c5a129a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Tue, 29 Aug 2023 10:50:20 +0200 Subject: [PATCH] fix(i18n): timestamp stripping year part Use locale-neutral `getDayMonth()` plus the time part as there's no way to programatically check for date parts separator. Fixes #10615 --- ui/StatusQ/src/StatusQ/Core/LocaleUtils.qml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ui/StatusQ/src/StatusQ/Core/LocaleUtils.qml b/ui/StatusQ/src/StatusQ/Core/LocaleUtils.qml index 3bb900431b..45c09291f5 100644 --- a/ui/StatusQ/src/StatusQ/Core/LocaleUtils.qml +++ b/ui/StatusQ/src/StatusQ/Core/LocaleUtils.qml @@ -431,17 +431,14 @@ QtObject { return qsTr("%1 %2").arg(loc.standaloneDayName(value.getDay(), Locale.ShortFormat)).arg(value.toLocaleTimeString(loc, formatString)) } - // otherwise - var fullFormatString = d.fixupTimeFormatString(loc.dateTimeFormat(Locale.ShortFormat)) + // within this year if (now.getFullYear() === value.getFullYear()) { - // strip year part, if current year -> "31 December 09:41" - // It remove preceding dot or space - fullFormatString = fullFormatString.replace(/([.\s])?\b(y+)\b/g, "") - } else if (!fullFormatString.includes("yyyy")) { - fullFormatString = fullFormatString.replace("yy", "yyyy") // different year -> "31 December 2022 09:41" + // strip year part, if current year -> "31 Dec 09:41" + return getDayMonth(value) + " " + formatTime(value, Locale.ShortFormat) } - return value.toLocaleString(loc, fullFormatString) + // otherwise + return formatDateTime(value, Locale.ShortFormat) } function getTimeDifference(d1, d2) {