2023-11-28 13:18:25 +00:00
|
|
|
import type { Reaction } from '../../../graphql/schema/core.gen'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-06-12 17:58:02 +00:00
|
|
|
import { clsx } from 'clsx'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
|
|
|
import { useLocalize } from '../../../context/localize'
|
|
|
|
|
2023-07-02 05:08:42 +00:00
|
|
|
import styles from './CommentDate.module.scss'
|
2023-06-12 17:58:02 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
comment: Reaction
|
|
|
|
isShort?: boolean
|
|
|
|
isLastInRow?: boolean
|
2023-10-23 15:18:10 +00:00
|
|
|
showOnHover?: boolean
|
2023-06-12 17:58:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const CommentDate = (props: Props) => {
|
2023-10-18 10:56:41 +00:00
|
|
|
const { t, formatDate } = useLocalize()
|
2023-06-12 17:58:02 +00:00
|
|
|
|
2023-10-18 10:56:41 +00:00
|
|
|
const formattedDate = (date: number) => {
|
2023-06-16 14:47:24 +00:00
|
|
|
const formatDateOptions: Intl.DateTimeFormatOptions = props.isShort
|
|
|
|
? { month: 'long', day: 'numeric', year: 'numeric' }
|
|
|
|
: { hour: 'numeric', minute: 'numeric' }
|
|
|
|
|
|
|
|
return formatDate(new Date(date), formatDateOptions)
|
|
|
|
}
|
2023-06-12 17:58:02 +00:00
|
|
|
|
|
|
|
return (
|
2023-10-23 15:18:10 +00:00
|
|
|
<div
|
|
|
|
class={clsx(styles.commentDates, {
|
|
|
|
[styles.commentDatesLastInRow]: props.isLastInRow,
|
2023-11-14 15:10:00 +00:00
|
|
|
[styles.showOnHover]: props.showOnHover,
|
2023-10-23 15:18:10 +00:00
|
|
|
})}
|
|
|
|
>
|
2023-11-28 13:18:25 +00:00
|
|
|
<time class={styles.date}>{formattedDate(props.comment.created_at * 1000)}</time>
|
2023-06-12 17:58:02 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|