refactor: make use of Qt.locale

This commit is contained in:
Pascal Precht 2021-01-04 15:47:25 +01:00 committed by Iuri Matias
parent eca5622439
commit f9b7d9dfc9
3 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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))
}
}