From b257ccc87d456d8e34776c8b49efa232dc51cfd0 Mon Sep 17 00:00:00 2001 From: Cuteivist Date: Thu, 3 Aug 2023 10:45:05 +0200 Subject: [PATCH] fix(@desktop/wallet): Fix section label (#11755) --- ui/imports/shared/views/HistoryView.qml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui/imports/shared/views/HistoryView.qml b/ui/imports/shared/views/HistoryView.qml index 93b0f67bda..c8e405f515 100644 --- a/ui/imports/shared/views/HistoryView.qml +++ b/ui/imports/shared/views/HistoryView.qml @@ -136,11 +136,18 @@ ColumnLayout { return qsTr("Earlier this week") } else if (daysToBeginingOfThisWeek > -7) { return qsTr("Last week") - } else if (currDate.getMonth() === timestampDate.getMonth()) { + } else if (currDate.getMonth() === timestampDate.getMonth() && currDate.getYear() === timestampDate.getYear()) { return qsTr("Earlier this month") - } else if ((new Date(new Date().setDate(0))).getMonth() === timestampDate.getMonth()) { + } + + const previousMonthDate = (new Date(new Date().setDate(0))) + // Special case for the end of the year + if ((timestampDate.getMonth() === previousMonthDate.getMonth() && timestampDate.getYear() === previousMonthDate.getYear()) + || (previousMonthDate.getMonth() === 11 && timestampDate.getMonth() === 0 && Math.abs(timestampDate.getYear() - previousMonthDate.getYear()) === 1)) + { return qsTr("Last month") } + return timestampDate.toLocaleDateString(Qt.locale(), "MMM yyyy") } }