Batch import of calendar data

I’m looking for a way to import calendar data from a file of data. Doubtless I’ll need to write this myself based on what the core ‘add event’ function does. Can someone point me at the code for this function? I’m guessing that it’s probably in /concrete/blocks/calendar_event somewhere.

Or where the system & settings > calendar > import calendar data is implemented - that must have similar logic to it.

hello. there is a faulty export method but no import method as far as I know.
the addEvent() method is easy-ish to replicate. It’s here:

Thanks for that. Very helpful!

Not sure if this will be helpful, but I’m in the process of integrating “meetings” with Concrete calendars. Meetings have what you would expect - a title, description, date/time, etc. When a meeting is added (via a dashboard form), an event is added to the selected calendar.

I’m in the process of developing a bulk import for legacy meetings, but here’s a method to add meetings to the calendar (refactored from this post - 8.4.2: using concrete5 calendar programmatically - concrete5).

class Meetings extends DashboardPageController
    private function addMeetingToCalendar($meeting, $calendar)
        $dateStart = $meeting->getStartDate()->format("Y-m-d H:i:s");
        $dateEnd = $meeting->getStartDate()->format("Y-m-d H:i:s");
        $title = $meeting->getTitle();
        $description = $meeting->getDescription();

        $timezone = $calendar->getSite()->getConfigRepository()->get('timezone');
        if (!$timezone) {
            $timezone = date_default_timezone_get();
        $timezone = new \DateTimeZone($timezone);

        $pd = new EventRepetition();
        $pdEntity = new CalendarEventRepetition($pd);
        $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
        $eventService = $app->make(EventService::class);
        $u = new User();

        $event = new CalendarEvent($calendar);
        $eventVersion = $eventService->getVersionToModify($event, $u);

        $repetitions[] = new CalendarEventVersionRepetition($eventVersion, $pdEntity);
        $eventService->addEventVersion($event, $calendar, $eventVersion, $repetitions);

        $pkr = new ApproveCalendarEventRequest();
        $response = $pkr->trigger();
        return $event->getID();