const IMMINENT_STATUS_DURATION_MS = 1800000; // 30 minutes type Status = { value: 'upcoming' | 'imminent' | 'started'; endsAt: string | null; }; export const getMeetingStatus = (startsAt: Date): Status => { const now = new Date(); const remainingTime = startsAt.getTime() - now.getTime(); if (remainingTime < 0) { return { value: 'started', endsAt: null, }; } if (remainingTime < IMMINENT_STATUS_DURATION_MS) { return { value: 'imminent', endsAt: startsAt.toISOString(), }; } return { value: 'upcoming', endsAt: new Date(startsAt.getTime() - IMMINENT_STATUS_DURATION_MS).toISOString(), }; };