feat: format timestamp in TransactionBubble like the Chat

This commit is contained in:
Jonathan Rainville 2020-08-26 11:15:40 -04:00 committed by Iuri Matias
parent 9e2bf87d84
commit 60f7a3cbe2
3 changed files with 10 additions and 8 deletions

View File

@ -6,12 +6,7 @@ StyledTextEdit {
id: chatTime id: chatTime
visible: isMessage visible: isMessage
color: Style.current.darkGrey color: Style.current.darkGrey
text: { text: Utils.formatTime(timestamp)
let messageDate = new Date(Math.floor(timestamp))
let minutes = messageDate.getMinutes();
let hours = messageDate.getHours();
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
}
font.pixelSize: 10 font.pixelSize: 10
readOnly: true readOnly: true
selectByMouse: true selectByMouse: true

View File

@ -9,7 +9,7 @@ Rectangle {
property string fiatValue: "10 USD" property string fiatValue: "10 USD"
property bool outgoing: true property bool outgoing: true
property string state: "addressReceived" property string state: "addressReceived"
property string time: "9:41 AM" property int timestamp: 1598454756329
id: root id: root
width: 170 width: 170
@ -111,7 +111,7 @@ Rectangle {
StyledText { StyledText {
id: timeText id: timeText
color: Style.current.secondaryText color: Style.current.secondaryText
text: root.time text: Utils.formatTime(root.timestamp)
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.bottomMargin: 9 anchors.bottomMargin: 9
anchors.right: parent.right anchors.right: parent.right

View File

@ -84,4 +84,11 @@ QtObject {
function setColorAlpha(color, alpha) { function setColorAlpha(color, alpha) {
return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha) return Qt.hsla(color.hslHue, color.hslSaturation, color.hslLightness, alpha)
} }
function formatTime(timestamp) {
let messageDate = new Date(Math.floor(timestamp))
let minutes = messageDate.getMinutes();
let hours = messageDate.getHours();
return (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes)
}
} }