1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Backport pull request #6265 from jellyfin-web/release-10.10.z

Add support for plugin revisions with bad timestamps

Original-merge: 71ab6fea5d

Merged-by: thornbill <thornbill@users.noreply.github.com>

Backported-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
thornbill 2024-11-03 10:54:30 -05:00 committed by Joshua M. Boniface
parent 4f17bfb5ed
commit 0ff58e81b0
2 changed files with 19 additions and 3 deletions

View file

@ -9,7 +9,7 @@ import Stack from '@mui/material/Stack/Stack';
import React, { type FC } from 'react'; import React, { type FC } from 'react';
import MarkdownBox from 'components/MarkdownBox'; import MarkdownBox from 'components/MarkdownBox';
import { parseISO8601Date, toLocaleString } from 'scripts/datetime'; import { getDisplayDateTime } from 'scripts/datetime';
import globalize from 'lib/globalize'; import globalize from 'lib/globalize';
import type { PluginDetails } from '../types/PluginDetails'; import type { PluginDetails } from '../types/PluginDetails';
@ -32,7 +32,7 @@ const PluginRevisions: FC<PluginRevisionsProps> = ({
{version.version} {version.version}
{version.timestamp && (<> {version.timestamp && (<>
&nbsp;&mdash;&nbsp; &nbsp;&mdash;&nbsp;
{toLocaleString(parseISO8601Date(version.timestamp))} {getDisplayDateTime(version.timestamp)}
</>)} </>)}
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>

View file

@ -203,12 +203,28 @@ export function toLocaleTimeString(date, options) {
return date.toLocaleTimeString(); 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) { export function getDisplayTime(date) {
if (!date) { if (!date) {
throw new Error('date cannot be null'); throw new Error('date cannot be null');
} }
if ((typeof date).toString().toLowerCase() === 'string') { if (typeof date === 'string') {
try { try {
date = parseISO8601Date(date, true); date = parseISO8601Date(date, true);
} catch (err) { } catch (err) {