From 108cf73a307f248b1dbc9cb943c75a1adf431f0a Mon Sep 17 00:00:00 2001
From: Artem Baskal <a.baskal@adguard.com>
Date: Tue, 24 Dec 2019 00:29:10 +0300
Subject: [PATCH] + client: show date in query logs

---
 client/src/components/Logs/index.js | 14 ++++++++------
 client/src/helpers/helpers.js       | 13 +++++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/client/src/components/Logs/index.js b/client/src/components/Logs/index.js
index 449a6538..940769ef 100644
--- a/client/src/components/Logs/index.js
+++ b/client/src/components/Logs/index.js
@@ -9,6 +9,7 @@ import { HashLink as Link } from 'react-router-hash-link';
 import {
     formatTime,
     formatDateTime,
+    formatTodayDate,
 } from '../../helpers/helpers';
 import { SERVICES, FILTERED_STATUS, TABLE_DEFAULT_PAGE_SIZE } from '../../helpers/constants';
 import { getTrackerData } from '../../helpers/trackers/trackers';
@@ -115,11 +116,12 @@ class Logs extends Component {
     checkWhiteList = reason => reason === FILTERED_STATUS.NOT_FILTERED_WHITE_LIST;
 
     getTimeCell = ({ value }) => (
-        <div className="logs__row">
-            <span className="logs__text" title={formatDateTime(value)}>
-                {formatTime(value)}
-            </span>
-        </div>
+            <div className="logs__row">
+                    <span className="logs__text" title={formatDateTime(value)}>
+                        {formatTodayDate(value) === formatTodayDate(Date.now())
+                            ? formatTime(value) : formatDateTime(value)}
+                    </span>
+            </div>
     );
 
     getDomainCell = (row) => {
@@ -257,7 +259,7 @@ class Logs extends Component {
             {
                 Header: t('time_table_header'),
                 accessor: 'time',
-                maxWidth: 100,
+                minWidth: 105,
                 Cell: this.getTimeCell,
             },
             {
diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js
index 8f9556af..53a821f0 100644
--- a/client/src/helpers/helpers.js
+++ b/client/src/helpers/helpers.js
@@ -39,6 +39,19 @@ export const formatDateTime = (dateTime) => {
     return parsedTime.toLocaleString(currentLanguage, options);
 };
 
+export const formatTodayDate = (dateTime) => {
+    const currentLanguage = i18n.languages[0] || 'en';
+    const parsedTime = dateParse(dateTime);
+    const options = {
+        year: 'numeric',
+        month: 'numeric',
+        day: 'numeric',
+        hour12: false,
+    };
+
+    return parsedTime.toLocaleString(currentLanguage, options);
+};
+
 export const normalizeLogs = logs => logs.map((log) => {
     const {
         time,