From a9c4cc91671b01b07a8c1950753925faf8fc7c64 Mon Sep 17 00:00:00 2001 From: Julio Zynger Date: Tue, 1 Mar 2022 14:13:57 +0100 Subject: [PATCH] Replace moment with luxon Signed-off-by: Julio Zynger --- plugins/periskop/package.json | 3 ++- .../components/PeriskopErrorsTable/PeriskopErrorsTable.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/periskop/package.json b/plugins/periskop/package.json index c6fc02a308..661efc23c3 100644 --- a/plugins/periskop/package.json +++ b/plugins/periskop/package.json @@ -30,7 +30,7 @@ "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.57", - "moment": "^2.29.1", + "luxon": "^2.0.2", "react-use": "^17.2.4" }, "peerDependencies": { @@ -46,6 +46,7 @@ "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^13.1.8", "@types/jest": "^26.0.7", + "@types/luxon": "^2.0.4", "@types/node": "^14.14.32", "cross-fetch": "^3.1.5", "msw": "^0.35.0" diff --git a/plugins/periskop/src/components/PeriskopErrorsTable/PeriskopErrorsTable.tsx b/plugins/periskop/src/components/PeriskopErrorsTable/PeriskopErrorsTable.tsx index 54f97b0700..ae299c6128 100644 --- a/plugins/periskop/src/components/PeriskopErrorsTable/PeriskopErrorsTable.tsx +++ b/plugins/periskop/src/components/PeriskopErrorsTable/PeriskopErrorsTable.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import moment from 'moment'; +import { DateTime } from 'luxon'; import { Entity } from '@backstage/catalog-model'; import { useApi } from '@backstage/core-plugin-api'; import { useEntity } from '@backstage/plugin-catalog-react'; @@ -69,7 +69,9 @@ const renderSeverity = (severity: string): React.ReactNode => { }; const renderLastOccurrence = (error: AggregatedError): React.ReactNode => { - return moment(new Date(error.latest_errors[0].timestamp * 1000)).fromNow(); + return DateTime.fromMillis( + error.latest_errors[0].timestamp * 1000, + ).toRelative(); }; function isNotFoundInInstance(