From 7944fa04af140adfbdab2dfcfd32c689adca6dd4 Mon Sep 17 00:00:00 2001 From: James Pretorius Date: Tue, 5 Dec 2023 14:47:44 -0500 Subject: [PATCH] Handle null time --- FU.SPA/src/components/PostCard.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/FU.SPA/src/components/PostCard.jsx b/FU.SPA/src/components/PostCard.jsx index 8b35a23d..50939036 100644 --- a/FU.SPA/src/components/PostCard.jsx +++ b/FU.SPA/src/components/PostCard.jsx @@ -8,10 +8,14 @@ import { } from '@mui/material'; const PostCard = ({ post }) => { - const dateTimeString = new Date(post.startTime).toLocaleString('en-US', { - dateStyle: 'medium', - timeStyle: 'short', - }); + let dateTimeString = 'Unspecified time'; + + if (post.startTime) { + dateTimeString = new Date(post.startTime).toLocaleString('en-US', { + dateStyle: 'medium', + timeStyle: 'short', + }); + } return (