iCal get a lot of events real slow

I have a calendar which has one event per week from 1994-2010. I want to use it for an application I am building in AppleScript Studio but getting all the events into a list is a real slow process.


tell application "iCal"
tell calendar "isoWeeks"
set eventList to every event
end tell
end tell

is there a faster way of doing this? I thought about just dumping every event into a MySQL database to make retrieving them faster.

For the app I am getting a file create date, resetting it to the Monday of that week, then comparing it to the calendar to get the comparable event (date wise) for that Monday. (Hope that made sense).

Any suggestions would be appreciated.

Getting every event does appear to take an extraordinary amount of time. But it’s not clear from your description that you actually need to do that. Assuming from the name of your calendar that we’re talking Monday-start weeks, and assuming further (unwarrantedly) that the events all occur on the Mondays and that they’re all-day events, the following would suffice, which doesn’t take very long:

set knownWeekStart to date "Monday 6 January 1000 00:00:00"

set relevantWeekStart to fileDate - (fileDate - knownWeekStart) mod weeks

tell application "iCal"
	set relevantEvent to first event of calendar "isoWeeks" whose start date is relevantWeekStart
end tell

If the events might occur at any time in their respective weeks, the following is only a little slower:

set knownWeekStart to date "Monday 6 January 1000 00:00:00"

set relevantWeekStart to fileDate - (fileDate - knownWeekStart) mod weeks

tell application "iCal"
	set relevantEvent to first event of calendar "isoWeeks" whose (start date ≥ relevantWeekStart) and (start date < (relevantWeekStart + weeks))
end tell

PS. I love the fact that iCal’s process icon in the Dock (and in DragThing docks) always shows the current date. :cool: