NOBUG: fix linter error

This commit is contained in:
Yuqiu Wang
2022-02-22 09:49:14 -06:00
parent e9a3ce7c61
commit 855587e90e
2 changed files with 14 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
import React from 'react';
import Field from './field';
import {objectMap} from './listViewHelpers';
import {safeParseTimeToDate} from '../utils/dates'
import {safeParseTimeToDate} from '../utils/dates';
const MetadataFields = ({item}: {[key: string]: any}) => (
<>

View File

@@ -1,5 +1,5 @@
import HumanizeDuration from "humanize-duration";
import { k8s } from "../proto/proto";
import HumanizeDuration from 'humanize-duration';
import {k8s} from '../proto/proto';
/**
* A simple humanizer to merely differentiate between months and minutes.
@@ -27,22 +27,22 @@ const shortEnglishHumanizer = HumanizeDuration.humanizer({
*
*/
export default function fromNow(
epochtimestampMs: number | string | k8s.io.apimachinery.pkg.apis.meta.v1.ITime
epochtimestampMs: number | string | k8s.io.apimachinery.pkg.apis.meta.v1.ITime,
) {
const diff = Date.now() - safeParseTimeToDate(epochtimestampMs).getTime();
return formatDuration(diff);
const diff = Date.now() - safeParseTimeToDate(epochtimestampMs).getTime();
return formatDuration(diff);
}
export function safeParseTimeToDate(
epochtimestampMs: number | string | k8s.io.apimachinery.pkg.apis.meta.v1.ITime
epochtimestampMs: number | string | k8s.io.apimachinery.pkg.apis.meta.v1.ITime,
) {
if (
typeof epochtimestampMs !== "number" &&
typeof epochtimestampMs !== "string"
) {
epochtimestampMs = Number(epochtimestampMs.seconds) * 1000;
}
return new Date(epochtimestampMs);
if (
typeof epochtimestampMs !== 'number'
&& typeof epochtimestampMs !== 'string'
) {
return new Date(Number(epochtimestampMs.seconds) * 1000);
}
return new Date(epochtimestampMs);
}