From 908a9615c17608b45a2c5d517290fbf5e648250f Mon Sep 17 00:00:00 2001 From: Peter Fitzgibbons Date: Wed, 20 Dec 2023 09:19:07 -0800 Subject: [PATCH] Correct convertDateTime output on invalid/missing date Signed-off-by: Peter Fitzgibbons --- public/components/common/query_utils/index.ts | 2 +- .../__tests__/__snapshots__/para_output.test.tsx.snap | 2 +- .../notebooks/components/paragraph_components/para_output.tsx | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/public/components/common/query_utils/index.ts b/public/components/common/query_utils/index.ts index 489afad130..73e137bc12 100644 --- a/public/components/common/query_utils/index.ts +++ b/public/components/common/query_utils/index.ts @@ -74,7 +74,7 @@ export const convertDateTime = ( const epochTime = myDate.getTime() / 1000.0; return Math.round(epochTime); } - if (formatted) return returnTime!.utc().format(PPL_DATE_FORMAT); + if (formatted) return returnTime?.utc()?.format(PPL_DATE_FORMAT); return returnTime; }; diff --git a/public/components/notebooks/components/paragraph_components/__tests__/__snapshots__/para_output.test.tsx.snap b/public/components/notebooks/components/paragraph_components/__tests__/__snapshots__/para_output.test.tsx.snap index a149d56beb..50d7f2081b 100644 --- a/public/components/notebooks/components/paragraph_components/__tests__/__snapshots__/para_output.test.tsx.snap +++ b/public/components/notebooks/components/paragraph_components/__tests__/__snapshots__/para_output.test.tsx.snap @@ -72,6 +72,6 @@ exports[` spec renders visualization outputs 1`] = ` class="euiText euiText--small" style="margin-left: 9px;" > - 2020-07-21T18:37:44+00:00 - 2020-08-20T18:37:44+00:00 + 2020-07-21 18:37:44.710000 - 2020-07-21 18:37:44.710000 `; diff --git a/public/components/notebooks/components/paragraph_components/para_output.tsx b/public/components/notebooks/components/paragraph_components/para_output.tsx index 1202682f72..ef3dc4097d 100644 --- a/public/components/notebooks/components/paragraph_components/para_output.tsx +++ b/public/components/notebooks/components/paragraph_components/para_output.tsx @@ -103,7 +103,6 @@ const OutputBody = ({ const to = convertDateTime(visInput?.timeRange?.from, false, false); const displayFrom = convertDateTime(visInput?.timeRange?.from, true) || 'Invalid date'; const displayTo = convertDateTime(visInput?.timeRange?.from, false) || 'Invalid date'; - console.log('display', { displayFrom, displayTo, from, to, dateFormat }); if (typeOut !== undefined) { switch (typeOut) { case 'QUERY':