Skip to content

Instantly share code, notes, and snippets.

@cmer
Created August 9, 2025 04:32
Show Gist options
  • Save cmer/1b3b3a55eccbac2aa220d77c937d2bcd to your computer and use it in GitHub Desktop.
Save cmer/1b3b3a55eccbac2aa220d77c937d2bcd to your computer and use it in GitHub Desktop.
Paper school calendar parser

Create an .ics of important dates for the school year

Parse the provided text or OCR transcription of the school calendar and generate a standards-compliant .ics file containing every event. Handle dates, times, recurrence, and grade-specific rules precisely as follows.

Variables to respect

  • SCHOOL NAME = Jane Doe Elementary
  • CHILD GRADE = 1
  • SCHOOL YEAR = 2025–2026

Event Titles

  • Prefix every event with: "[SCHOOL NAME HERE] - ".
  • If an event’s time is unknown or unparseable, append — TIME TBD to the name.
  • If an event’s date is TBD, set the date to the first of that month and append — EXACT DATE TBD to the name.

Dates

  • A single date → create a single event.
  • A range of dates without times (e.g., “Nov 24–28 Thanksgiving Break”) → create one multi-day all-day event.
  • A range of dates with a time → do not create a multi-day block. Instead:
  • Create a recurring daily event using RRULE:FREQ=DAILY;COUNT=n (one occurrence per day in the range).
  • Use the same time for every occurrence in the series.

Times

Parse times in h:mm-h:mm am/pm or h:mm-h:mm formats and infer AM/PM as needed, assuming no events take place in the middle of the night:

  • If both start and end hours are 4–11, assume PM.
  • If both are 7–10, assume AM.
  • If ambiguous, default to AM (except 12:00 defaults to PM).
  • If only a start time is given, assume a 30-minute duration (unless specified otherwise).
  • If times are described in text for specific grades (e.g., “11:45 PK and 12:00 K–4”), use the time for my child's grade.
  • If a time is unparseable, mark the event as all-day and append — TIME TBD to the title.

Descriptions

  • Put the original event text verbatim (including original times and any grade notes) in the event’s DESCRIPTION field of the .ics entry.

Recurrence

  • Use recurring events only when the same event repeats on consecutive days with the same start/end time.
  • Do not use recurrence for unrelated events on different dates.

Output Requirements

Produce a fully valid .ics file that includes:

  • Correct DTSTART/DTEND:
  • Timed events: include TZID=America/Chicago.
  • All-day events: use VALUE=DATE.
  • A unique UID for every event.
  • RRULE for recurring events per the rules above.
  • No multi-day timed events (only all-day multi-day where applicable).

Deliverables

  1. The finalized .ics file.
  2. A clean, human-readable table listing:
  • Event name
  • Date(s)
  • Time
  • Recurrence type (Single, Multi-day, Recurring)

Review

Thoroughly review every event. The final output must be error-free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment