CourseKitStarPlan
iCal Parser
Parse RFC 5545 VEVENTs from a raw iCal string into structured ParsedVEvent records
parseIcal reads a raw iCal string (typically returned from StarPlanClient.fetchIcal) and returns a ParsedVEvent[]. It is a tiny, dependency-free parser tailored for StarPlan's VEVENT output.
Usage
import { parseIcal, type ParsedVEvent } from '@hfu.digital/coursekit-starplan';
const events: ParsedVEvent[] = parseIcal(icalString);
// or with a custom study-block grid
const events2 = parseIcal(icalString, { studyBlocks: myCustomConfig });ParsedVEvent
| Field | Type | Description |
|---|---|---|
uid | string | iCal UID, or a synthetic fallback if omitted |
summary | string | Event title |
description | string | undefined | Event description |
dtstart | Date | Local-time start instant (no timezone shift applied) |
dtend | Date | Local-time end instant |
location | string | undefined | Free-form LOCATION (pass to extractRoom) |
rrule | string | null | RFC 5545 RRULE if present (e.g. FREQ=WEEKLY;BYDAY=MO;COUNT=14) |
weekday | number | 0 = Sunday … 6 = Saturday |
studyBlock | number | null | 1-based study-block index, or null if outside the configured grid |
Options — ParseIcalOptions
| Option | Type | Default | Description |
|---|---|---|---|
studyBlocks | StudyBlockConfig | HFU_STUDY_BLOCK_CONFIG | Daily grid used to resolve studyBlock. See study-blocks. |
Helpers
import { groupBySchedule, groupBySummary } from '@hfu.digital/coursekit-starplan';
// Group events by (summary + weekday + studyBlock + room)
const bySchedule = groupBySchedule(events);
// Group events by summary only
const bySummary = groupBySummary(events);These produce Map<string, ParsedVEvent[]> results useful for de-duplication, snapshotting, and feeding detectChanges.
Notes
- Times are parsed as local time — the parser does not apply timezone shifts. If you need timezone-aware comparison, normalize at write time.
dtstartfalling exactly on a study-block boundary is inclusive of that block; the gap between two blocks (e.g. HFU 09:30–09:45) snaps forward to the next block.- If
DTSTARTorDTENDis missing or unparsable, the VEVENT is skipped silently.