X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f5c0cb11102a006cda59711f29458b7569b9a21f..badcb86fb7d0e2ab87c7dcef230072db2e2ae95e:/src/common/formatters.ts diff --git a/src/common/formatters.ts b/src/common/formatters.ts index e2097878..377e78e4 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -2,13 +2,21 @@ // // SPDX-License-Identifier: AGPL-3.0 -export const formatDate = (isoDate?: string) => { +import { PropertyValue } from "~/models/search-bar"; + +export const formatDate = (isoDate?: string | null, utc: boolean = false) => { if (isoDate) { const date = new Date(isoDate); - const text = date.toLocaleString(); - return text === 'Invalid Date' ? "" : text; + let text: string; + if (utc) { + text = date.toUTCString(); + } + else { + text = date.toLocaleString(); + } + return text === 'Invalid Date' ? "(none)" : text; } - return ""; + return "(none)"; }; export const formatFileSize = (size?: number) => { @@ -67,3 +75,12 @@ const FILE_SIZES = [ unit: "B" } ]; + +export const formatPropertyValue = (pv: PropertyValue) => { + if (pv.key) { + return pv.value + ? `${pv.key}: ${pv.value}` + : pv.key; + } + return ""; +};