X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fb48b7f876cf7c8b402ba05c16dffaade0a9f655..796a3ce005800d37ef5711b367c926ac720577d5:/src/common/formatters.ts diff --git a/src/common/formatters.ts b/src/common/formatters.ts index 0402f39037..377e78e42a 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -2,10 +2,21 @@ // // SPDX-License-Identifier: AGPL-3.0 -export const formatDate = (isoDate: string) => { - const date = new Date(isoDate); - const text = date.toLocaleString(); - return text === 'Invalid Date' ? "" : text; +import { PropertyValue } from "~/models/search-bar"; + +export const formatDate = (isoDate?: string | null, utc: boolean = false) => { + if (isoDate) { + const date = new Date(isoDate); + let text: string; + if (utc) { + text = date.toUTCString(); + } + else { + text = date.toLocaleString(); + } + return text === 'Invalid Date' ? "(none)" : text; + } + return "(none)"; }; export const formatFileSize = (size?: number) => { @@ -64,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 ""; +};