ProSchedulerSign in

Scheduler · Data

Import an .ics calendar

parseIcs turns an iCalendar file — an export from Google Calendar, Outlook or Apple Calendar — into events: all-day and timed, time zones, recurring rules and their exceptions.

Live demo

Find the standup that's missing on one day · Open an .ics file of your own

Fullscreen
import { useState } from "react"
import { parseIcs, ProScheduler, type SchedulerEvent } from "@andreisaac/pro-scheduler"
import { sampleIcs } from "./data/integrations"
import { Choice, Toolbar, useEvents } from "./kit"

export function IcsImportDemo() {
  const { events, setEvents, handlers } = useEvents<SchedulerEvent>(() => parseIcs(sampleIcs()))
  const [note, setNote] = useState(`Imported ${events.length} events from the sample calendar.`)
  const load = (text: string, name: string) => {
    const imported = parseIcs(text)
    setEvents(imported)
    setNote(`Imported ${imported.length} events from ${name}.`)
  }
  return (
    <>
      <Toolbar label="Import">
        <Choice onClick={() => load(sampleIcs(), "the sample calendar")}>Load sample</Choice>
        <label className="docs-demo__file">
          Open an .ics file…
          <input
            type="file"
            accept=".ics,text/calendar"
            className="sr-only"
            onChange={async (e) => {
              const file = e.target.files?.[0]
              if (file) load(await file.text(), file.name)
              e.target.value = ""
            }}
          />
        </label>
        <span className="text-sm text-muted-foreground" aria-live="polite">
          {note}
        </span>
      </Toolbar>
      <ProScheduler
        data={events}
        view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00" } }}
        height={600}
        {...handlers}
      />
    </>
  )
}

About this demo

parseIcs turns an iCalendar file — an export from Google Calendar, Outlook or Apple Calendar — into events: all-day and timed, time zones, recurring rules and their exceptions.

Things to try

  • Find the standup that's missing on one day
  • Open an .ics file of your own

The props behind it are explained in Output and scale.

Use ProScheduler in your project