From 944840f040d3c7aac1e4fb911beb940c977b74df Mon Sep 17 00:00:00 2001 From: Sukanya Pandey Date: Tue, 4 Aug 2020 23:43:07 +0530 Subject: Remove date bug in event logs page - Before this commit the filtering on date for offset timing wasnt working. -After this commit the filtering on date for UTC as well for offset is working as expected. Signed-off-by: Sukanya Pandey Change-Id: Ib627ce944c269dfe52b2ac4fd5670786ec05bb1f --- src/components/Mixins/TableFilterMixin.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/Mixins/TableFilterMixin.js b/src/components/Mixins/TableFilterMixin.js index 7cb7007d..1a5425f9 100644 --- a/src/components/Mixins/TableFilterMixin.js +++ b/src/components/Mixins/TableFilterMixin.js @@ -30,14 +30,24 @@ const TableFilterMixin = { propertyKey = 'date' ) { if (!startDate && !endDate) return tableData; - const startDateInMs = startDate ? startDate.getTime() : 0; - const endDateInMs = endDate - ? endDate.getTime() - : Number.POSITIVE_INFINITY; + let startDateInMs = startDate ? startDate.getTime() : 0; + let endDateInMs = endDate ? endDate.getTime() : Number.POSITIVE_INFINITY; + + const isUtcDisplay = this.$store.getters['global/isUtcDisplay']; + + //Offset preference selected + if (!isUtcDisplay) { + startDateInMs = startDate + ? startDate.getTime() + startDate.getTimezoneOffset() * 60000 + : 0; + endDateInMs = endDate + ? endDate.getTime() + endDate.getTimezoneOffset() * 60000 + : Number.POSITIVE_INFINITY; + } + return tableData.filter(row => { const date = row[propertyKey]; if (!(date instanceof Date)) return; - const dateInMs = date.getTime(); if (dateInMs >= startDateInMs && dateInMs <= endDateInMs) return row; }); -- cgit v1.2.3