--- import { cn } from '../lib/cn' import { timeAgo } from '../lib/timeAgo' import type { Polymorphic } from 'astro/types' type Props = Polymorphic<{ as: Tag start: Date end?: Date | null classNames?: { fadedWords?: string } now?: Date }> const { start, end = null, classNames = {}, now = new Date(), as: Tag = 'span', ...htmlProps } = Astro.props const actualEndedAt = end ?? now const startedAtFormatted = timeAgo.format(start, 'twitter-minute-now') const isUpcoming = now < start const isOngoing = now >= start && (!end || now <= end) const endedAtFormatted = timeAgo.format(actualEndedAt, 'twitter-minute-now') const isOneTimeEvent = start === actualEndedAt || startedAtFormatted === endedAtFormatted --- { !end ? ( isUpcoming ? ( <> Upcoming on ) : ( <> Ongoing since ) ) : isOneTimeEvent ? ( isUpcoming ? ( <> Upcoming on ) : ( ) ) : ( <> {isUpcoming ? ( <> Upcoming from to ) : isOngoing ? ( <> Ongoing since to ) : ( <> From to )} ) }