Исправлено отображение времени стрима для старых дампов

This commit is contained in:
serega6531 2020-04-10 18:03:41 +03:00
parent 4a0cb2c91f
commit 28169642b4

View File

@ -10,7 +10,7 @@
<br/> <br/>
{{ dateToText(stream.startTimestamp) }} {{ dateToText(stream.startTimestamp) }}
<template v-if="!dateMatches(stream.startTimestamp, stream.endTimestamp)"> <template v-if="!dateMatches(stream.startTimestamp, stream.endTimestamp)">
- {{ dateToText(stream.endTimestamp) }} - {{ dateToText(stream.endTimestamp, dayMatches(stream.startTimestamp, stream.endTimestamp)) }}
</template> </template>
<template v-if="stream.userAgentHash"><br/>UA: {{ stream.userAgentHash }}</template> <template v-if="stream.userAgentHash"><br/>UA: {{ stream.userAgentHash }}</template>
<br/> <br/>
@ -45,14 +45,14 @@
}; };
}, },
methods: { methods: {
dateToText(unixTimestamp) { dateToText(unixTimestamp, short = false) {
const date = new Date(unixTimestamp); const date = new Date(unixTimestamp);
const options = { const options = {
hour: '2-digit', hour: '2-digit',
minute: '2-digit', minute: '2-digit',
second: '2-digit', second: '2-digit',
}; };
if (!this.isToday(date)) { if (!short && !this.isToday(date)) {
options.month = '2-digit'; options.month = '2-digit';
options.day = '2-digit'; options.day = '2-digit';
return date.toLocaleDateString('ru-RU', options); return date.toLocaleDateString('ru-RU', options);
@ -67,6 +67,15 @@
someDate.getFullYear() === today.getFullYear(); someDate.getFullYear() === today.getFullYear();
}, },
dayMatches(rFirst, rSecond) {
const first = new Date(rFirst);
const second = new Date(rSecond);
return first.getDate() === second.getDate() &&
first.getMonth() === second.getMonth() &&
first.getFullYear() === second.getFullYear();
},
dateMatches(rFirst, rSecond) { dateMatches(rFirst, rSecond) {
const first = new Date(rFirst); const first = new Date(rFirst);
const second = new Date(rSecond); const second = new Date(rSecond);