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
visible: isMessage
color: Style.current.darkGrey
text: {
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)
}
text: Utils.formatTime(timestamp)
font.pixelSize: 10
readOnly: true
selectByMouse: true

View File

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

View File

@ -84,4 +84,11 @@ QtObject {
function setColorAlpha(color, 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)
}
}