From d1ed8112bfd880237d2ce64305183b04a3ff23ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Midb=C3=B8e?= Date: Tue, 17 Mar 2020 10:37:08 +0100 Subject: [PATCH] Display date of message if not the same as today. --- src/ui/Chat.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ui/Chat.vue b/src/ui/Chat.vue index 79cbcee..e0da226 100644 --- a/src/ui/Chat.vue +++ b/src/ui/Chat.vue @@ -81,9 +81,14 @@ export default { }, getTime: function(timestamp) { let date = new Date(timestamp); - return `${this.pad(date.getHours())}:${this.pad( + const timeString = `${this.pad(date.getHours())}:${this.pad( date.getMinutes() )}:${this.pad(date.getSeconds())}`; + + if (date.getDate() == new Date().getDate()) { + return timeString; + } + return `${date.toLocaleDateString()} ${timeString}` }, sendMessage: function() { this.$emit("message", this.message);