)
}
const DateWidget = ({
date,
endDate,
eventTimeZone,
isHydrated,
}: {
date: string
endDate?: string
eventTimeZone: string
isHydrated: boolean
}) => {
const eventDate = new Date(date)
// Date-only Notion events are normalized to noon UTC (T12:00:00Z); detect them
// so we can display in UTC and suppress the fabricated time component.
const isDateOnly = date.endsWith('T12:00:00Z')
const timeZone = getEventTimeZone(date, eventTimeZone, isHydrated)
const formattedDate = eventDate.toLocaleDateString('en-US', {
weekday: 'long',
month: 'short',
day: 'numeric',
timeZone,
})
const currentYear = new Date().toLocaleDateString('en-US', { year: 'numeric' })
const eventYear = eventDate.toLocaleDateString('en-US', { year: 'numeric', timeZone })
// Always show the year until hydration: the server's clock can't decide the visitor's current year.
const formattedDateWithYear =
!isHydrated || eventYear !== currentYear ? `${formattedDate}, ${eventYear}` : formattedDate
const timeFormat = {
hour: 'numeric',
minute: '2-digit',
hour12: true,
timeZone,
timeZoneName: isHydrated ? undefined : 'short',
} as const
// Only show time for events that have a real time component
let timeDisplay: string | null = null
if (!isDateOnly) {
const startTime = eventDate.toLocaleTimeString('en-US', timeFormat)
if (endDate && !endDate.endsWith('T12:00:00Z')) {
const endEventDate = new Date(endDate)
const endTime = endEventDate.toLocaleTimeString('en-US', timeFormat)
timeDisplay = `${startTime} - ${endTime}`
} else {
timeDisplay = startTime
}
}
return (
{formattedDateWithYear}
{timeDisplay &&
{timeDisplay}
}
)
}
const LocationWidget = ({ location, categories }: { location?: string; categories?: string[] }) => {
// Webinars have no physical location; show a camera icon and the format instead.
if (categories?.includes('webinar')) {
return (