mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-15 01:48:16 -07:00
Merge pull request #6265 from thornbill/safe-plugin-dates
Add support for plugin revisions with bad timestamps
This commit is contained in:
commit
71ab6fea5d
@ -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<PluginRevisionsProps> = ({
|
||||
{version.version}
|
||||
{version.timestamp && (<>
|
||||
—
|
||||
{toLocaleString(parseISO8601Date(version.timestamp))}
|
||||
{getDisplayDateTime(version.timestamp)}
|
||||
</>)}
|
||||
</AccordionSummary>
|
||||
<AccordionDetails>
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user