diff --git a/components/ui/Comments.tsx b/components/ui/Comments.tsx index 8c9765d..59bcbe4 100644 --- a/components/ui/Comments.tsx +++ b/components/ui/Comments.tsx @@ -10,7 +10,7 @@ import {Button} from '@/components/ui/Button' import {GitHubIcon} from '@/components/icons/SocialIcons' import {ArrowLeftIcon} from '@/components/icons/ArrowLeftIcon' import {StatusMessage} from '@/components/ui/StatusMessage' -import {getShortDurationFromNow} from '@/lib/dateFns' +import {getShortDurationFromNow, truncateDatetime} from '@/lib/dateFns' import CommentFormProvider, {useCommentFormContext} from '@/app/context/CommentFormProvider' import type {Comment} from '@/types' @@ -19,6 +19,7 @@ type ReplyButton = { comment: Comment } + Comments.ReplyButton = function ReplyButton({comment}: ReplyButton) { const commentFormContext = useCommentFormContext() const {data: session} = useSession() @@ -62,7 +63,7 @@ Comments.Comment = function Comment({comment, isReply = false, className}: { {comment.user.name}

-

diff --git a/lib/dateFns.ts b/lib/dateFns.ts index 7c50c81..c8e272b 100644 --- a/lib/dateFns.ts +++ b/lib/dateFns.ts @@ -4,7 +4,9 @@ import { differenceInMinutes, differenceInMonths, differenceInWeeks, - differenceInYears + differenceInYears, + format, + parseISO } from 'date-fns' export function getShortDurationFromNow(fromDateTime: string) { @@ -28,3 +30,7 @@ export function getShortDurationFromNow(fromDateTime: string) { return '<1m' } + +export function truncateDatetime(datetime: string) { + return format(parseISO(datetime), 'yyyy-MM-dd\'T\'HH:mm') +}