* Builds a readable content string from a calendar event.
(event: CalendarEvent)
| 108 | * Builds a readable content string from a calendar event. |
| 109 | */ |
| 110 | function eventToContent(event: CalendarEvent): string { |
| 111 | const parts: string[] = [] |
| 112 | |
| 113 | parts.push(`Event: ${event.summary || 'Untitled Event'}`) |
| 114 | |
| 115 | if (isAllDayEvent(event)) { |
| 116 | parts.push(`Date: ${formatEventTime(event.start)} (All Day)`) |
| 117 | } else { |
| 118 | parts.push(`Date: ${formatEventTime(event.start)} - ${formatEventTime(event.end)}`) |
| 119 | } |
| 120 | |
| 121 | if (event.location) { |
| 122 | parts.push(`Location: ${event.location}`) |
| 123 | } |
| 124 | |
| 125 | const organizer = formatOrganizer(event.organizer) |
| 126 | if (organizer) { |
| 127 | parts.push(`Organizer: ${organizer}`) |
| 128 | } |
| 129 | |
| 130 | const attendees = formatAttendees(event.attendees) |
| 131 | if (attendees) { |
| 132 | parts.push(`Attendees: ${attendees}`) |
| 133 | } |
| 134 | |
| 135 | if (event.description) { |
| 136 | parts.push('') |
| 137 | parts.push('Description:') |
| 138 | parts.push( |
| 139 | event.description |
| 140 | .replace(/<[^>]*>/g, ' ') |
| 141 | .replace(/\s+/g, ' ') |
| 142 | .trim() |
| 143 | ) |
| 144 | } |
| 145 | |
| 146 | return parts.join('\n') |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Computes the default time range boundaries: 30 days in the past to 30 days in the future. |
no test coverage detected