Display date of message if not the same as today.

This commit is contained in:
2020-03-17 10:37:08 +01:00
parent 3ec5fb6e44
commit d1ed8112bf

View File

@@ -81,9 +81,14 @@ export default {
}, },
getTime: function(timestamp) { getTime: function(timestamp) {
let date = new Date(timestamp); let date = new Date(timestamp);
return `${this.pad(date.getHours())}:${this.pad( const timeString = `${this.pad(date.getHours())}:${this.pad(
date.getMinutes() date.getMinutes()
)}:${this.pad(date.getSeconds())}`; )}:${this.pad(date.getSeconds())}`;
if (date.getDate() == new Date().getDate()) {
return timeString;
}
return `${date.toLocaleDateString()} ${timeString}`
}, },
sendMessage: function() { sendMessage: function() {
this.$emit("message", this.message); this.$emit("message", this.message);