Modifying a Calendar event with calendar lib

This may be an obvious question - but I have trouble modifying a calendar event, by setting the ending time to an hour after start time. Appreciate any help please. Thanks:

use script "CalendarLib EC" version "1.1.3" -- put this at the top of your scripts
use scripting additions
use framework "Foundation"
use framework "AppKit"

set theStartDate to (current date)
set hours of theStartDate to 0
set minutes of theStartDate to 0
set seconds of theStartDate to 0
set theEndDate to theStartDate + (1 * days) - 1


set theStore to fetch store -- get the event store, which you need below
set theCalendars to fetch calendars "Calendar" event store theStore -- get the chosen calendars
set theEvents to fetch events starting date theStartDate ending date theEndDate searching cals theCalendars event store theStore -- get the events
set theEvents to filter events by pattern event list theEvents event summary "*" without using regex

repeat with nextEvent in theEvents
	
	set theInfo to event info for event nextEvent
	
	if (event_summary of theInfo) contains "MRN" then
		set newEndDate to ((event_start_date of theInfo) + (60 * minutes))
		set newEvent to modify event event nextEvent destination calendar theCalendars ending date newEndDate
		store event event newEvent event store theStore
	end if
	
end repeat

You’r variable theCalendars contains a list, but the destination calendar parameter of the modify event command requires a single calendar. You code works here if I change this:

set newEvent to modify event event nextEvent destination calendar theCalendars ending date newEndDate

to:

set newEvent to modify event event nextEvent destination calendar (item 1 of theCalendars) ending date newEndDate

You might also check that theCalendars isn’t an empty list.

Thanks so much Shane! Adding “item 1” did the trick - I missed that it was a list.
BTW - can this be also used in swift? I tried running some AppleScript in xcode - it works with regular statements, but not sure how to get it to load calendarlib

I’m not sure what you mean by “in swift”.

A use statement should be enough. You should probably also add the library to the project, so it’s embedded in the resulting app.