@@ -19,6 +19,7 @@ import ClockIcon from "@/app/conf/_design-system/pixelarticons/clock.svg?svgr"
1919
2020import { getEventTitle } from "../../utils"
2121import { CalendarIcon } from "@/app/conf/_design-system/pixelarticons/calendar-icon"
22+ import { formatBlockTime } from "./format-block-time"
2223
2324function isString ( x : unknown ) : x is string {
2425 return Object . prototype . toString . call ( x ) === "[object String]"
@@ -29,11 +30,13 @@ export function ScheduleSessionCard({
2930 year,
3031 eventsColors,
3132 blockEnd,
33+ durationVisible,
3234} : {
3335 session : ScheduleSession
3436 year : `202${number } `
3537 eventsColors : Record < string , string >
3638 blockEnd : Date
39+ durationVisible : boolean
3740} ) {
3841 let eventType = session . event_type
3942
@@ -139,17 +142,7 @@ export function ScheduleSessionCard({
139142 { session . venue }
140143 </ span >
141144 ) }
142- { blockTimeFraction < 1 && (
143- < span className = "typography-body-xs flex items-center gap-0.5" >
144- < ClockIcon className = "size-4 text-pri-base [@container(width<240px)]:hidden" />
145- { Math . round (
146- ( new Date ( session . event_end ) . getTime ( ) -
147- new Date ( session . event_start ) . getTime ( ) ) /
148- ( 1000 * 60 ) ,
149- ) } { " " }
150- min
151- </ span >
152- ) }
145+ { durationVisible && < SessionDuration session = { session } /> }
153146 < AddToCalendarLink
154147 eventTitle = { eventTitle }
155148 session = { session }
@@ -164,6 +157,29 @@ export function ScheduleSessionCard({
164157 )
165158}
166159
160+ function SessionDuration ( {
161+ session,
162+ } : {
163+ session : ScheduleSession
164+ } ) : React . ReactNode {
165+ const durationMs =
166+ new Date ( session . event_end ) . getTime ( ) -
167+ new Date ( session . event_start ) . getTime ( )
168+
169+ // if a session is longer than 3 hourse, we show the time range
170+ const formattedTime =
171+ durationMs > 1000 * 60 * 60 * 3
172+ ? formatBlockTime ( session . event_start , new Date ( session . event_end ) )
173+ : `${ Math . round ( durationMs / ( 1000 * 60 ) ) } min`
174+
175+ return (
176+ < span className = "typography-body-xs flex items-center gap-0.5" >
177+ < ClockIcon className = "size-4 text-pri-base [@container(width<240px)]:hidden" />
178+ { formattedTime }
179+ </ span >
180+ )
181+ }
182+
167183function AddToCalendarLink ( {
168184 eventTitle,
169185 session,
0 commit comments