added local time to event

This commit is contained in:
xdrm-brackets 2017-12-07 20:17:04 +01:00
parent 8a649dbf0b
commit 62b353eea9
2 changed files with 18 additions and 1 deletions

View File

@ -29,7 +29,6 @@ export default {
local_date: function(id){ local_date: function(id){
/* (1) Get current date */ /* (1) Get current date */
var cur = new Date( gstore.data.notif.emergency.data[id].timestamp ); var cur = new Date( gstore.data.notif.emergency.data[id].timestamp );
console.log(cur);
/* (2) First line -> show whole date */ /* (2) First line -> show whole date */
if( id < 1 ) if( id < 1 )

View File

@ -5,6 +5,7 @@
<div v-for='(msg, id) in gstore.notif.event.data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.event.data[id-1][0] != gstore.notif.event.data[id][0] ? "1" : "0"'> <div v-for='(msg, id) in gstore.notif.event.data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.event.data[id-1][0] != gstore.notif.event.data[id][0] ? "1" : "0"'>
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif.event.data[id-1][0] != msg[0]'></span> <span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif.event.data[id-1][0] != msg[0]'></span>
<span class='content' v-html='bbcode(msg[1])'></span> <span class='content' v-html='bbcode(msg[1])'></span>
<span class='date' v-text='local_date(id)'></span>
</div> </div>
<div class='end-pad'></div> <!-- End Spacing --> <div class='end-pad'></div> <!-- End Spacing -->
@ -25,6 +26,23 @@ export default {
name: 'CONTAINER_EVENT', name: 'CONTAINER_EVENT',
data(){ return { gstore: gstore.data }; }, data(){ return { gstore: gstore.data }; },
methods: { 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){ new_message(msg){
/* (1) If empty message -> abort */ /* (1) If empty message -> abort */