From 18f0608c309e9af9ce5491158cbe8e24a47ba45c Mon Sep 17 00:00:00 2001 From: mrfry Date: Sun, 30 May 2021 10:53:18 +0200 Subject: [PATCH] Date display fixes --- src/components/comments.js | 9 +++++++-- src/components/newsEntry.js | 8 +++++++- src/pages/userfiles.js | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/comments.js b/src/components/comments.js index 863011c..c43c503 100644 --- a/src/components/comments.js +++ b/src/components/comments.js @@ -41,6 +41,7 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) { const [displayed, setDisplayed] = useState(true) const [commenting, setCommenting] = useState(false) const { content, subComments, date, user, reacts, admin } = comment + const dateObj = new Date(date) const own = uid === user const commentStyle = admin @@ -67,9 +68,13 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) { User #{user} -
@ {date}
-
{date}
+
+ @ + {dateObj.getDate() !== new Date().getDate() + ? dateObj.toLocaleDateString() + : dateObj.toLocaleTimeString()} +
{content}
diff --git a/src/components/newsEntry.js b/src/components/newsEntry.js index 0ce935c..aad95c3 100644 --- a/src/components/newsEntry.js +++ b/src/components/newsEntry.js @@ -16,6 +16,7 @@ export default function NewsEntry({ onPostDelete, }) { const { reacts, title, content, user, comments, date, admin } = newsItem + const dateObj = new Date(date) return (
@@ -34,7 +35,12 @@ export default function NewsEntry({ User #{user} -
@ {date}
+
+ @ + {dateObj.getDate() !== new Date().getDate() + ? dateObj.toLocaleDateString() + : dateObj.toLocaleTimeString()} +
{admin ? ( diff --git a/src/pages/userfiles.js b/src/pages/userfiles.js index 6d40a65..bc904a6 100644 --- a/src/pages/userfiles.js +++ b/src/pages/userfiles.js @@ -354,7 +354,7 @@ export default function UserFiles({ router, globalData }) { >
{name}
- {new Date(date).toDateString()} + {new Date(date).toLocaleDateString()}
{currDir