diff --git a/src/apps/dashboard/features/plugins/components/PluginRevisions.tsx b/src/apps/dashboard/features/plugins/components/PluginRevisions.tsx index fe4c5743fc..815ac6ae05 100644 --- a/src/apps/dashboard/features/plugins/components/PluginRevisions.tsx +++ b/src/apps/dashboard/features/plugins/components/PluginRevisions.tsx @@ -9,7 +9,7 @@ import Stack from '@mui/material/Stack/Stack'; import React, { type FC } from 'react'; import MarkdownBox from 'components/MarkdownBox'; -import { parseISO8601Date, toLocaleString } from 'scripts/datetime'; +import { getDisplayDateTime } from 'scripts/datetime'; import globalize from 'lib/globalize'; import type { PluginDetails } from '../types/PluginDetails'; @@ -32,7 +32,7 @@ const PluginRevisions: FC = ({ {version.version} {version.timestamp && (<>  —  - {toLocaleString(parseISO8601Date(version.timestamp))} + {getDisplayDateTime(version.timestamp)} )} diff --git a/src/scripts/datetime.js b/src/scripts/datetime.js index d48e0e6d84..6de53c0167 100644 --- a/src/scripts/datetime.js +++ b/src/scripts/datetime.js @@ -203,12 +203,28 @@ export function toLocaleTimeString(date, options) { return date.toLocaleTimeString(); } +export function getDisplayDateTime(date) { + if (!date) { + throw new Error('date cannot be null'); + } + + if (typeof date === 'string') { + try { + date = parseISO8601Date(date, true); + } catch (err) { + return date; + } + } + + return toLocaleString(date); +} + export function getDisplayTime(date) { if (!date) { throw new Error('date cannot be null'); } - if ((typeof date).toString().toLowerCase() === 'string') { + if (typeof date === 'string') { try { date = parseISO8601Date(date, true); } catch (err) {