From 62b353eea91074e67f1eb9e087e422109fa6067f Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 7 Dec 2017 20:17:04 +0100 Subject: [PATCH] added local time to event --- view/vue/container/emergency.vue | 1 - view/vue/container/event.vue | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/view/vue/container/emergency.vue b/view/vue/container/emergency.vue index fd456f3..7094152 100644 --- a/view/vue/container/emergency.vue +++ b/view/vue/container/emergency.vue @@ -29,7 +29,6 @@ export default { local_date: function(id){ /* (1) Get current date */ var cur = new Date( gstore.data.notif.emergency.data[id].timestamp ); - console.log(cur); /* (2) First line -> show whole date */ if( id < 1 ) diff --git a/view/vue/container/event.vue b/view/vue/container/event.vue index 180aacc..f96b542 100644 --- a/view/vue/container/event.vue +++ b/view/vue/container/event.vue @@ -5,6 +5,7 @@
+
@@ -25,6 +26,23 @@ export default { name: 'CONTAINER_EVENT', data(){ return { gstore: gstore.data }; }, methods: { + local_date: function(id){ + /* (1) Get current date */ + var cur = new Date( gstore.data.notif.event.data[id].timestamp ); + + /* (2) First line -> show whole date */ + if( id < 1 ) + return cur.toLocaleString(); + + /* (3) Get previous date */ + var pre = new Date( gstore.data.notif.event.data[id-1].timestamp ); + + /* (2) If same day -> show time only */ + if( cur.toLocaleDateString() == pre.toLocaleDateString() ) + return cur.toLocaleTimeString(); + + return cur.toLocaleString(); + }, new_message(msg){ /* (1) If empty message -> abort */