I need to determine the date from now, adding 10 working days. Working days are, in my case, Mon-Fri, plus any regional holidays (christmas etc.). My Calendar app has included a calendar that defines those holidays.
Now I wonder if I can script Calendar.app to calculate these date offsets. I’d first take the start date (e.g. today’s) and add a day, checking whether it’s Mon-Fri. If so, I count these days until my limit has been reached. I also have to check whether it’s a holiday. So I’d get the holidays calender and see if that day contains an event on that day. But how do I do that?
I’ve looked at its dictionary, and browsed it with Script Debugger.
I found that when I run this code:
tell application id "com.apple.iCal" -- Calendar
tell its calendar "National Holidays"
tell its event 2
start date
end tell
end tell
end tell
Then it takes SEVERAL SECONDS to get my the result. The particular calendar has 800 entries (holidays for several years in advance). This is on 10.12.6. Did not try later macOS versions, yet.
Can this be optimized? Or is this a known issue with the extreme slowness here?