Skip to content

Commit

Permalink
Use a formatDateTime func
Browse files Browse the repository at this point in the history
  • Loading branch information
gildub committed Jun 26, 2024
1 parent 39f6760 commit 3788e76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 9 additions & 9 deletions client/src/app/pages/importer-list/importer-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ import {
useDeleteiIporterMutation as useDeleteIporterMutation,
useFetchImporters,
} from "@app/queries/importers";
import { formatDate, getAxiosErrorMessage } from "@app/utils/utils";
import {
formatDate,
formatDateTime,
getAxiosErrorMessage,
} from "@app/utils/utils";

import { FilterToolbar, FilterType } from "@app/components/FilterToolbar";
import { SimplePagination } from "@app/components/SimplePagination";
Expand Down Expand Up @@ -251,21 +255,17 @@ export const ImporterList: React.FC = () => {
modifier="truncate"
{...getTdProps({ columnKey: "start" })}
>
{!configValues?.disabled
? dayjs(item.report?.startDate)
.utc()
.format("YYYY-MM-DD HH:mm:ss")
{!configValues?.disabled && item.report?.startDate
? formatDateTime(item.report?.startDate)
: null}
</Td>
<Td
width={15}
modifier="truncate"
{...getTdProps({ columnKey: "end" })}
>
{!configValues?.disabled
? dayjs(item.report?.endDate)
.utc()
.format("YYYY-MM-DD HH:mm:ss")
{!configValues?.disabled && item.report?.endDate
? formatDateTime(item.report?.endDate)
: null}
</Td>
<Td
Expand Down
5 changes: 4 additions & 1 deletion client/src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AxiosError } from "axios";
import dayjs from "dayjs";
import { PackageURL } from "packageurl-js";

import { RENDER_DATE_FORMAT } from "@app/Constants";
import { RENDER_DATETIME_FORMAT, RENDER_DATE_FORMAT } from "@app/Constants";
import { DecomposedPurl } from "@app/api/models";
import { ToolbarChip } from "@patternfly/react-core";

Expand Down Expand Up @@ -38,6 +38,9 @@ export const formatDate = (value?: string) => {
return value ? dayjs(value).format(RENDER_DATE_FORMAT) : undefined;
};

export const formatDateTime = (value: string) =>
dayjs(value).utc().format(RENDER_DATETIME_FORMAT);

export const duplicateFieldCheck = <T>(
fieldKey: keyof T,
itemList: T[],
Expand Down

0 comments on commit 3788e76

Please sign in to comment.