Skip to content

Commit

Permalink
datetooltip forcetime
Browse files Browse the repository at this point in the history
  • Loading branch information
kearfy committed Apr 12, 2024
1 parent 9398a1d commit 239b73d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/[locale]/(public)/e/[event]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default function Page() {
Start of event
</h3>
<p className="text-sm text-foreground/75">
<DateTooltip date={event.start} />
<DateTooltip date={event.start} forceTime />
</p>
</div>
)}
Expand All @@ -196,7 +196,7 @@ export default function Page() {
End of event
</h3>
<p className="text-sm text-foreground/75">
<DateTooltip date={event.end} />
<DateTooltip date={event.end} forceTime />
</p>
</div>
)}
Expand Down
10 changes: 8 additions & 2 deletions src/components/miscellaneous/DateTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ dayjs.extend(duration);
dayjs.extend(localizedFormat);
dayjs.extend(relativeTime);

export function DateTooltip({ date }: { date: Date }) {
export function DateTooltip({
date,
forceTime,
}: {
date: Date;
forceTime?: boolean;
}) {
return (
<TooltipProvider>
<Tooltip delayDuration={200}>
<TooltipTrigger asChild>
<span>
{date.getTime() > new Date().getTime()
? dayjs(date).format('ll')
? dayjs(date).format(forceTime ? 'lll' : 'll')
: dayjs.duration(dayjs(date).diff()).humanize(true)}
</span>
</TooltipTrigger>
Expand Down

0 comments on commit 239b73d

Please sign in to comment.