From f9b7d9dfc98134950f13f7d7631fe45e7e960431 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 4 Jan 2021 15:47:25 +0100 Subject: [PATCH] refactor: make use of Qt.locale --- .../AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml | 2 +- ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml | 2 +- ui/imports/Utils.qml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml index c939d3e8cc..de8eec70d4 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/MessageComponents/ChatTime.qml @@ -7,7 +7,7 @@ StyledTextEdit { id: chatTime visible: isMessage color: Style.current.darkGrey - text: formatDateTime ? Utils.formatDateTime(timestamp) : Utils.formatTime(timestamp) + text: formatDateTime ? Utils.formatDateTime(timestamp, appSettings.locale) : Utils.formatTime(timestamp, appSettings.locale) font.pixelSize: Style.current.asideTextFontSize readOnly: true selectByMouse: true diff --git a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml index 38a6049ad9..4290bd0818 100644 --- a/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml +++ b/ui/app/AppLayouts/Chat/ContactsColumn/Channel.qml @@ -119,7 +119,7 @@ Rectangle { StyledText { id: contactTime - text: Utils.formatDateTime(wrapper.timestamp) + text: Utils.formatDateTime(wrapper.timestamp, appSettings.locale) anchors.right: parent.right anchors.rightMargin: !isCompact ? Style.current.padding : Style.current.smallPadding anchors.top: !isCompact ? parent.top : undefined diff --git a/ui/imports/Utils.qml b/ui/imports/Utils.qml index a0a227f024..deca2759fa 100644 --- a/ui/imports/Utils.qml +++ b/ui/imports/Utils.qml @@ -130,7 +130,7 @@ QtObject { return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) } - function formatDateTime(timestamp) { + function formatDateTime(timestamp, locale) { let now = new Date() let yesterday = new Date() yesterday.setDate(now.getDate()-1) @@ -155,7 +155,7 @@ QtObject { qsTr("Saturday")]; return days[messageDate.getDay()]; } else { - return messageDate.getMonth()+1+"/"+messageDate.getDate()+"/"+messageDate.getFullYear() + return new Date().toLocaleDateString(Qt.locale(locale)) } }