Skip to content

Commit 5225c4e

Browse files
committed
Display time range in session details
1 parent 27f67c9 commit 5225c4e

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

src/app/conf/2025/schedule/[id]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { CtaCardSection } from "../../components/cta-card-section"
2222
import { Button } from "@/app/conf/_design-system/button"
2323
import { SessionTags } from "../../components/session-tags"
2424
import { formatDescription } from "./format-description"
25+
import { formatBlockTime } from "../_components/format-block-time"
2526

2627
type SessionProps = { params: { id: string } }
2728

@@ -194,10 +195,15 @@ function SessionHeader({
194195
<div className="flex items-center gap-2">
195196
<CalendarIcon className="size-5 text-sec-darker dark:text-sec-light/90 sm:size-6" />
196197
<time dateTime={event.event_start}>
197-
{new Date(event.event_start).toLocaleDateString("en-US", {
198+
{new Date(event.event_start).toLocaleString("en-US", {
198199
day: "numeric",
199200
month: "long",
200201
})}
202+
{", "}
203+
{formatBlockTime(
204+
event.event_start,
205+
event.event_end ? new Date(event.event_end) : undefined,
206+
)}
201207
</time>
202208
</div>
203209
<div className="flex items-center gap-2">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { parseISO } from "date-fns"
2+
3+
const timeFormat = new Intl.DateTimeFormat(undefined, {
4+
hour: "2-digit",
5+
minute: "2-digit",
6+
})
7+
export const formatBlockTime = (start: string, end?: Date) => {
8+
const startDate = parseISO(start)
9+
if (end) {
10+
return timeFormat.formatRange(startDate, end)
11+
}
12+
return timeFormat.format(startDate)
13+
}

src/app/conf/2025/schedule/_components/schedule-list.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
FilterStates,
1717
ResetFiltersButton,
1818
} from "./filters"
19+
import { formatBlockTime } from "./format-block-time"
1920

2021
export interface FiltersConfig
2122
extends Partial<
@@ -101,19 +102,6 @@ function getSessionsByDay(
101102
}
102103
}
103104

104-
const timeFormat = new Intl.DateTimeFormat(undefined, {
105-
hour: "2-digit",
106-
minute: "2-digit",
107-
})
108-
const formatBlockTime = (start: string, end?: string) => {
109-
const startDate = parseISO(start)
110-
if (end) {
111-
const endDate = parseISO(end)
112-
return timeFormat.formatRange(startDate, endDate)
113-
}
114-
return timeFormat.format(startDate)
115-
}
116-
117105
export interface ScheduleListProps {
118106
showFilter?: boolean
119107
scheduleData: ScheduleSession[]
@@ -205,8 +193,18 @@ export function ScheduleList({
205193
</h3>
206194
{Object.entries(concurrentSessionsGroup).map(
207195
([sessionDate, sessions], i, blocks) => {
208-
const blockEnd = sessions[0]?.event_end
209-
const nextBlockStart = blocks[i + 1]?.[0]
196+
const blockEnd = new Date(
197+
Math.max(
198+
...sessions.map(session =>
199+
new Date(session.event_end).getTime(),
200+
),
201+
),
202+
)
203+
204+
const nextBlock = blocks[i + 1]
205+
const nextBlockStart = nextBlock?.[0]
206+
? new Date(nextBlock[0])
207+
: undefined
210208

211209
const isBreak =
212210
sessions[0]?.event_type

0 commit comments

Comments
 (0)