Date display fixes

This commit is contained in:
mrfry 2021-05-30 10:53:18 +02:00
parent 5369f942f6
commit 18f0608c30
3 changed files with 15 additions and 4 deletions

View file

@ -41,6 +41,7 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
const [displayed, setDisplayed] = useState(true) const [displayed, setDisplayed] = useState(true)
const [commenting, setCommenting] = useState(false) const [commenting, setCommenting] = useState(false)
const { content, subComments, date, user, reacts, admin } = comment const { content, subComments, date, user, reacts, admin } = comment
const dateObj = new Date(date)
const own = uid === user const own = uid === user
const commentStyle = admin const commentStyle = admin
@ -67,9 +68,13 @@ function Comment({ comment, index, onComment, onDelete, onReact, uid }) {
User #{user} User #{user}
</a> </a>
</Link> </Link>
<div className={styles.newsDate}> @ {date}</div>
</div> </div>
<div className={styles.commentDate}>{date}</div> <div className={styles.commentDate} title={dateObj.toLocaleString()}>
@
{dateObj.getDate() !== new Date().getDate()
? dateObj.toLocaleDateString()
: dateObj.toLocaleTimeString()}
</div>
</div> </div>
<div className={`${!displayed && styles.hidden}`}> <div className={`${!displayed && styles.hidden}`}>
<div className={styles.commentText}> {content}</div> <div className={styles.commentText}> {content}</div>

View file

@ -16,6 +16,7 @@ export default function NewsEntry({
onPostDelete, onPostDelete,
}) { }) {
const { reacts, title, content, user, comments, date, admin } = newsItem const { reacts, title, content, user, comments, date, admin } = newsItem
const dateObj = new Date(date)
return ( return (
<div className={styles.newsRoot}> <div className={styles.newsRoot}>
@ -34,7 +35,12 @@ export default function NewsEntry({
User #{user} User #{user}
</a> </a>
</Link> </Link>
<div className={styles.newsDate}> @ {date}</div> <div className={styles.newsDate} title={dateObj.toLocaleString()}>
@
{dateObj.getDate() !== new Date().getDate()
? dateObj.toLocaleDateString()
: dateObj.toLocaleTimeString()}
</div>
</div> </div>
</div> </div>
{admin ? ( {admin ? (

View file

@ -354,7 +354,7 @@ export default function UserFiles({ router, globalData }) {
> >
<div>{name}</div> <div>{name}</div>
<div title={new Date(date).toLocaleString()}> <div title={new Date(date).toLocaleString()}>
{new Date(date).toDateString()} {new Date(date).toLocaleDateString()}
</div> </div>
<div> <div>
{currDir {currDir