updated timestamp conversion to use Luxon and adrs-adr012 guideline, added luxon as dependency

Signed-off-by: Jeremy Guarini <jguarini@paloaltonetworks.com>
This commit is contained in:
Jeremy Guarini
2021-11-08 09:29:21 -08:00
parent a5512851a0
commit 367e3bf130
2 changed files with 6 additions and 1 deletions
+1
View File
@@ -33,6 +33,7 @@
"@material-ui/lab": "4.0.0-alpha.57",
"@material-ui/styles": "^4.11.0",
"highlight.js": "^10.6.0",
"luxon": "^2.1.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router": "6.0.0-beta.0",
@@ -46,6 +46,8 @@ import { codeCoverageApiRef } from '../../api';
import { Progress, ResponseErrorPanel } from '@backstage/core-components';
import { useApi } from '@backstage/core-plugin-api';
import { DateTime } from 'luxon';
type Coverage = 'line' | 'branch';
const useStyles = makeStyles<BackstageTheme>(theme => ({
@@ -71,7 +73,9 @@ const getTrendIcon = (trend: number, classes: ClassNameMap) => {
// convert timestamp to human friendly form
function formatDateToHuman(timeStamp: string | number) {
return new Date(timeStamp).toUTCString();
return DateTime.fromMillis(Number(timeStamp)).toLocaleString(
DateTime.DATETIME_MED,
);
}
export const CoverageHistoryChart = () => {